Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClassNotFound Exception with classes of my own project 5.5.1

See original GitHub issue

I am developing a project using playframework and when I try to use dozer for some mappings, I get a ClassNotFoundException with classes that are part of my own project. I suspect it has something to do with the class loader (as explained here) of play, which might not be compatible with this version (even though when using dozer 5.4.0 I have no problem at all)

[info] play.api.Play$ - Application started (Dev)
[info] o.d.DozerBeanMapper - Initializing a new instance of dozer bean mapper.
[info] o.d.DozerBeanMapper - Using the following xml files to load custom mappings for the bean mapper instance: [dozerMapping.xml]
[info] o.d.DozerBeanMapper - Trying to find xml mapping file: dozerMapping.xml
[info] o.d.DozerBeanMapper - Using URL [file:/Users/cdparra/Projects/appcivist/appcivist-platform/target/scala-2.11/classes/dozerMapping.xml] to load custom xml mappings
[error] o.d.l.x.MappingStreamReader - Error while loading dozer mapping InputStream: []
org.dozer.MappingException: java.lang.ClassNotFoundException: models.location.Location
    at org.dozer.util.MappingUtils.throwMappingException( ~[dozer-5.5.1.jar:na]
    at org.dozer.util.DefaultClassLoader.loadClass( ~[dozer-5.5.1.jar:na]
    at org.dozer.util.MappingUtils.loadClass( ~[dozer-5.5.1.jar:na]
    at org.dozer.loader.DozerBuilder$MappingBuilder.classA( ~[dozer-5.5.1.jar:na]
    at org.dozer.loader.xml.XMLParser.parseMapping( ~[dozer-5.5.1.jar:na]
    at ~[dozer-5.5.1.jar:na]
    at ~[dozer-5.5.1.jar:na]
    at ~[dozer-5.5.1.jar:na]
    at [dozer-5.5.1.jar:na]
    at org.dozer.DozerBeanMapper.loadFromFiles( [dozer-5.5.1.jar:na]
Caused by: java.lang.ClassNotFoundException: models.location.Location
    at$ ~[na:1.8.0_25]
    at$ ~[na:1.8.0_25]
    at Method) ~[na:1.8.0_25]
    at ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass( ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass( ~[na:1.8.0_25]
    at java.lang.Class.forName0(Native Method) ~[na:1.8.0_25]
    at java.lang.Class.forName( ~[na:1.8.0_25]
    at org.apache.commons.lang3.ClassUtils.getClass( ~[commons-lang3-3.4.jar:3.4]
    at org.apache.commons.lang3.ClassUtils.getClass( ~[commons-lang3-3.4.jar:3.4]

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

christianmenzcommented, Apr 7, 2016

Took me quite a while to figure out what the problem was for me. I can’t tell for sure as I don’t know your exact setup, but maybe this helps other people searching for a solution. I’m using dozer in an enterprise application and dozer jar is loaded by the EARLibClassLoader (the app by the EARAppClassLoader).

Dozer does this:

DozerClassLoader classLoader = new DefaultClassLoader(getClass().getClassLoader());

Which imho is the wrong classloader for loading the classes in my dozer mapping file. I fixed this by adding this line of code before creating the mapper:

BeanContainer.getInstance().setClassLoader(new DefaultClassLoader(Thread.currentThread().getContextClassLoader()));

garethahealycommented, Apr 5, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix ClassNotFoundException in Java - Rollbar
The Java ClassNotFoundException occurs when the JVM tries to load a class but does not find it in the classpath. Learn the three...
Read more >
Class not found error, but class definitely exists - java
At first "Clean" and "Sync Project with Gradle Files". Then run your code.
Read more >
ClassNotFoundException vs NoClassDefFoundError - Baeldung
Both ClassNotFoundException and NoClassDefFoundError occur when the JVM can not find a requested class on the classpath.
Read more >
Configure jrun4 in myEclipse 5.5.1 GA - Genuitec
Everything seems fine except that the jars in my project classpath are not ... ClassNotFoundException: com.uhc.ubh.laww.cert.controller.
Read more >
Virgo » Error configuring application listener - Eclipse
I guess you want to make the Spring XmlWebApplicationContext class available through the osgi mechanism. But our own com.myCompany.myApps.web.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found