• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I'm trying to add some datas to the database through session bean and Hibernate. But while adding I'm getting the following error:

<Aug 20, 2009 11:16:58 AM IST> <Error> <HTTP> <BEA-101019> <[ServletContext@6753530[app:Ptrack module:PtrackWeb path:/PtrackWeb spec-version:null]] Servlet failed with IOException
java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at weblogic.ejb.container.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:103)
at weblogic.ejb.container.internal.BaseRemoteObject.handleSystemException(BaseRemoteObject.java:857)
at weblogic.ejb.container.internal.BaseRemoteObject.handleSystemException(BaseRemoteObject.java:809)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:514)
at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:60)
Truncated. see log file for complete stacktrace
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at com.ilink.ptrack.comps.functionalityEJB.dao.functionalityDAOImpl.getFunctionalityID(functionalityDAOImpl.java:389)
at com.ilink.ptrack.comps.functionalityFacade.functionalitySessionBean.currentFunctionality(functionalitySessionBean.java:56)
at com.ilink.ptrack.comps.functionalityFacade.functionalitySession_npbzmi_EOImpl.currentFunctionality(functionalitySession_npbzmi_EOImpl.java:587)
at com.ilink.ptrack.comps.functionalityFacade.functionalitySession_npbzmi_EOImpl_CBV.currentFunctionality(Unknown Source)
at ptrack.web.Functionality.FunctionalityDelegate.currentFunctionality(FunctionalityDelegate.java:75)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
Truncated. see log file for complete stacktrace
>

I kept the hibernate3.jar file in the WEB-INF/lib folder.

Please help me on this.

Thanks & Regards,
Midhun
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I kept the hibernate3.jar file in the WEB-INF/lib folder.


That NoClassDefFoundError appears to be coming from the EJB container. If you are using Hibernate form your EJBs you will need to put hibernate in the EJB application's classpath, not a web application's classpath.
 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for responding.....

Sorry to say,I kept the hibernate3.jar in WEB-INF/lib folder and set the Web application libraries classpath in EJB.

Regards,
Midhun



 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Midhun Sivasankaran wrote:

But I have set the path in the EJB.


Regards,
Midhun



 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure how WebLogic's classloaders work, so I'll move this to the WebLogic forum see if anyone over there knows.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put the jar directly under the EAR and change your EJB and WEB manifest so that they point to this jar. Does that solve your problem ?
 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,

I have done the same, but the error persists...

Regards,
MIdhun
 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I need to look up for Hibernate JNDI in the session bean. If yes, please help me on that....

Regards,
Midhun
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Midhun Sivasankaran wrote:Do I need to look up for Hibernate JNDI in the session bean. If yes, please help me on that....

Regards,
Midhun



No. This is a class path problem.

Placing the JAR in the EAR should have solved the problem. Try debugging the class loader hierarchy. The class loaders that come with weblogic provide good info on toString() calls. They will give you the classpath that they can see
 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you explain it more clearly please.....

Regards,
MIdhun
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Weblogic loads classes using a class loader hierarchy. Here is a link to the WL 9.1 class loading page

http://e-docs.bea.com/wls/docs91/programming/classloading.html

You need to understand at which stages of the class loader your class is being loaded, if it is being loaded at all. If other JARs in the EAR are being loaded correctly, you can confirm the same by obtaining this hierarchy. Get the current class loader in your code and get its parent recursively. You can then print the details of each class loader, and type cast to a specific class loader (like ChangeAwareClassLoader) and execute its methods
 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works....thank you

Also I'm trying with JNDI lookup in session bean. But getting an error:


NamingException is While trying to look up comp/env/hibernate/HibernateFactory in /app/ejb/PtrackEJB.jar#functionalitySession.



See my code

hibernate.cfg.xml


<hibernate-configuration>
<session-factory name="java:comp/env/hibernate/HibernateFactory">

<property name="dialect"> org.hibernate.dialect.SQLServerDialect </property>
<property name="hibernate.jdbc.use_get_generated_keys"> false </property>
<property name="hibernate.connection.url"> jdbc:weblogic:sqlserver://164.164.40.133:1433;DatabaseName=PtrackDevelop </property>
<property name=".hibernate.connection.driver_class"> weblogic.jdbc.sqlserver.SQLServerDriver </property>
<property name="hibernate.connection.username"> ptrackdeveloper </property>
<property name="hibernate.connection.password"> ptrackdeveloper </property>
<property name="show_sql"> true </property >
<property name="jndi.name">java:comp/env/hibernate/HibernateFactory</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="jndi.url">t3://localhost:7001</property>;
<property name="hibernate.session_factory_name">java:comp/env/hibernate/HibernateFactory</property>
<property name="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</property>
<mapping resource="/Functionality.hbm.xml"/>

</session-factory>
</hibernate-configuration>



Sessionbean.java

private Session createHibernateBean(){
Session session = null;
try{
Context context = new InitialContext();
System.out.println("Inside Create Hibernate bean..");
SessionFactory sessionfactory = (SessionFactory)context.lookup("java:comp/env/hibernate/HibernateFactory");
System.out.println("Sesision factory..."+sessionfactory.toString());
session = sessionfactory.getCurrentSession();
}catch(NamingException ne){
System.out.println("NamingException is "+ne.getMessage());
}
return session;
}



Please help me on this.

Regards,
Midhun
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have minimal experience with hibernate. However i can see that the JNDI name is not bound and is causing a naming exception. Check the JNDI tree in weblogic and you will be able to find out if the name is bound correctly. You can access the JNDI tree from the admin console
 
reply
    Bookmark Topic Watch Topic
  • New Topic