on 07-13-2010 6:45 PM
Hi, I need some help about resolving dependecies at runtime between DC's.
Version: 7.0 SP21
Project: J2EE, EJB Stateless, Hibernate and WebDynpro.
- Hibernate jars in External Library Project and deployed by J2EE Library Project.
- Java Project containing DAO java classes implemented with Hibernate. Deployed by J2EE Library Project.
- EJB Project containing EJB Stateless using DAO classes in Java Project to database persistence.
- Java Project containing Command Beans to implement Java Bean Model accessed by Web Dynpro. Deployed by J2EE Library.
The problem is that I received always "NoClassDefFoundException" from Command Beans when accesing Hibernate classes and also from DAO's in EJB's.
How should I define this dependencies correcly at design time?
How can classes in a Library Project "see" classes or jar's in another one at runtime?
Thanks in advance.
Hi Jorge,
Did you include your DAO Java DC in the EJB DC as used DC? Did you wrap your EJB with an EAR DC and deploy it?
http://wiki.sdn.sap.com/wiki/display/WDJava/CreatinganEJBandinvokinginWebdynpro+Java
Did you include the EAR DC in your Command Bean Java DC (as used DC)? Did you include the EAR as reference in your WD?
Please provide more details and you'll probably get more help if you post your question in the WD Java (or Java programming) forum.
Hope it helps.
Regards,
Dao
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Jorge,
I think than we have the same problem.
We also use version 7.0 SP21, similar scenario, and I see a problem with class loaders. This is my stack trace:
...
Caused by: java.lang.ExceptionInInitializerError
at net.tmb.bi.ejb.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:36)
at net.tmb.bi.ejb.BiFacadeBean.getConceptes(BiFacadeBean.java:47)
at net.tmb.bi.ejb.BiFacadeObjectImpl0_0.getConceptes(BiFacadeObjectImpl0_0.java:119)
... 26 more
Caused by: org.hibernate.MappingException: entity class not found: my.own.package.MyBeanModelClass
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:122)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:191)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at net.tmb.bi.ejb.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:32)
... 28 more
Caused by: java.lang.ClassNotFoundException: my.own.package.MyBeanModelClass
------------------------- Loader Info -------------------------
ClassLoader name: [library:mycompany.com~HibernateLib]
Parent loader name: [Frame ClassLoader]
No references !
Resources:
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\slf4j-jdk14-1.5.8.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\hibernate3.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\jta-1.1.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\dom4j-1.6.1.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\commons-collections-3.1.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\javassist-3.9.0.GA.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\antlr-2.7.6.jar
D:\usr\sap\WSD\JC00\j2ee\cluster\server0\bin\ext\mycompany.com~HibernateLib\slf4j-api-1.5.8.jar
Loading model: {parent,local,references}
---------------------------------------------------------------
at com.sap.engine.frame.core.load.ReferencedLoader.loadClass(ReferencedLoader.java:382)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:119)
... 37 more
From my point of view, whats happening here is that the method buildSessionfFactory called from hibernate Configuration class (usign hibernate.cfg.xml file) is not using the application class loader, only the referenced by the hibernate shared library.
Using the same library I have another application working without problems, but I'm not able to use the same shared library in eny other application.
I hope that any of the Gurus in this forum give us an answer...
Esteve
Solved.
The problem was solved adding the following references:
- From Command Beans Java Project to Hibernate Jars Project (Build and Run Time)
- From EJB Project to DAO Java Project (Build Time)
- From EAR Project to Java Library Project (Build and Deploy Time) containing Command Beans Java Project and DAO Java Project.
- From EAR Project to Java Library Project (Build and Deploy Time) containing Hibernate jars.
Thaks a lot.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.