ClassNotFound Exception with classes of my own project 5.5.1
See original GitHub issueI 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: [java.io.BufferedInputStream@1fd14bad]
org.dozer.MappingException: java.lang.ClassNotFoundException: models.location.Location
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82) ~[dozer-5.5.1.jar:na]
at org.dozer.util.DefaultClassLoader.loadClass(DefaultClassLoader.java:43) ~[dozer-5.5.1.jar:na]
at org.dozer.util.MappingUtils.loadClass(MappingUtils.java:224) ~[dozer-5.5.1.jar:na]
at org.dozer.loader.DozerBuilder$MappingBuilder.classA(DozerBuilder.java:129) ~[dozer-5.5.1.jar:na]
at org.dozer.loader.xml.XMLParser.parseMapping(XMLParser.java:190) ~[dozer-5.5.1.jar:na]
at org.dozer.loader.xml.XMLParser.read(XMLParser.java:137) ~[dozer-5.5.1.jar:na]
at org.dozer.loader.xml.XMLParser.read(XMLParser.java:43) ~[dozer-5.5.1.jar:na]
at org.dozer.loader.xml.MappingStreamReader.read(MappingStreamReader.java:51) ~[dozer-5.5.1.jar:na]
at org.dozer.loader.xml.MappingFileReader.read(MappingFileReader.java:58) [dozer-5.5.1.jar:na]
at org.dozer.DozerBeanMapper.loadFromFiles(DozerBeanMapper.java:227) [dozer-5.5.1.jar:na]
Caused by: java.lang.ClassNotFoundException: models.location.Location
at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_25]
at java.lang.Class.forName(Class.java:344) ~[na:1.8.0_25]
at org.apache.commons.lang3.ClassUtils.getClass(ClassUtils.java:909) ~[commons-lang3-3.4.jar:3.4]
at org.apache.commons.lang3.ClassUtils.getClass(ClassUtils.java:943) ~[commons-lang3-3.4.jar:3.4]
Issue Analytics
- State:
- Created 8 years ago
- Comments:7
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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()));
Duplicate of https://github.com/DozerMapper/dozer/issues/248