File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes java.lang.ClassNotFoundException: No ClassLoaders found for: myClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.lang.ClassNotFoundException: No ClassLoaders found for: myClass" Watch "java.lang.ClassNotFoundException: No ClassLoaders found for: myClass" New topic
Author

java.lang.ClassNotFoundException: No ClassLoaders found for: myClass

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Hibernate 4.0.1.Final. Hibernate is having trouble finding one of my classes, and it appears correctly spelled. In my hibernate.cfg.xml file (located at the root of my JAR), I have



I load the file like so



but when the above executes, the following exception is thrown …



However, I have verified that the class exists at the root of my JAR at com/myco/fdr/myproject/model/UserRole.class . Any ideas why Hibernate isn't able to track it down?

Thanks, - Dave
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Is the Hibernate jar in the classpath as well? Or did you perhaps decide to put the Hibernate jar into the JRE's extensions directory?
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi, The Hibernate classes are also getting included in my Jar. Why are you asking about that, though? The exception is complaining about one of my classes and in the stack trace, one of the Hibernate classes is successfully invoked. - Dave
Jo Joseph
Greenhorn

Joined: Nov 28, 2010
Posts: 23
Can you post some more code.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Well AnnotationConfiguration is deprecated. You should be using Configuration now.

so




Are you sure you are using javax.persistence.Entity instead of org.hibernate.annotation.Entity? If you are using the hibernate one by accident the AnnotationConfiguration class will ignore it. To test this you can try adding the class pragmatically instead and see what happens.




Also note that if you have a file called hibernate.cfg.xml on the root of classpath you do not need to specify it explicitly, as this is the default.

[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassNotFoundException: No ClassLoaders found for: myClass
 
Similar Threads
hbm file version working but annotation not
Hibernate exception problem
Initial SessionFactory creation exception with RAD
Pass textbox value to JSP custom tag
component class not found - but where should it be?