Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where to place hibernate.cfg.xml in case of a Ear Project

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

i am trying to use Hibernate inside EJB 3.0 Bean

When trying to access , EJB from my servlet , i am getting this Exception :

javax.ejb.EJBException: EJB Exception: ; nested exception is:
java.lang.NoClassDefFoundError: org/hibernate/Session; nested exception is: java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NoClassDefFoundError: org/hibernate/Session


By reading previous forums i made some modifications , but still it is not working .

Please tell me where exactly i should place hibernate.cfg.xml ??

Whether inside the EJB Module or inside the Ear ??
I am using Weblogic .
Please share your ideas .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Hibernate's default configuration mechanism it would be in the default package of your ejb application.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NoClassDefFoundError: org/hibernate/Session


That doesn't look like a problem finding the hibernate.cfg.xml file. That looks like a problem finding the org.hibernate.Session, which is in the hibernate.jar file.

Are you using Hibernate in your web or ejb layer? If it's in the web layer, put the hibernate jar in WEB-INF\lib. If it's in the EJB layer, put the hibernate jar in the EJB's lib directory. If it's in both, you can create a shared library right in the root of the ear. Again, here I'm talking about the hibernate.jar file, which contains the Session class. I'm not talking about the cfg.xml file, because I'm not convinced that the location of that file is your problem right now.

You might be having classloader issues. Here's a little thing I wrote on how classloaders work. It might be helpful if that's your problem:

Understanding J2EE/JEE Classloaders

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much , for your time and nice explanation .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic