Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21297
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post some more code.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic