tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: EJB classpath problem in eclipse3.5
Date Fri, 11 Sep 2009 23:44:50 GMT

On Sep 8, 2009, at 3:16 AM, sL07 wrote:

> hi all
> openEJB3.1.1 cant seem to find my EJB classes when in an eclipse 3.5  
> multi
> project workspace.
> I have project A, project B.
> Project A has the EJB classes.
> Project B has the openEJB test case.
> Project B reference Project A EJB's classes using 'add class folder'  
> in
> build path.
> The test correct compiles in eclipse but when it is executed in  
> Junit, it
> states it cant find reference to EJB.
> java.lang.IllegalArgumentException: Unknown entity:
> com.asteriski.itpflow.entity.ProjectActivityReference
> 	at
> org 
> .hibernate 
> .ejb 
> .AbstractEntityManagerImpl.persist(

This is actually a JPA thing (formerly part of the EJB spec).   
Basically, when you put a persistence.xml file in jar, the persistence  
provider (in this case Hibernate) will only look for @Entity classes  
in *that* jar per requirements of the JPA spec.

The only ways to get @Entity classes from other jars included is to  
via adding one or more the following to your <persistence-unit>  
declaration in your persistence.xml:

   - a <class> element that lists each of the @Entity classes
   - a <jar-file> element that lists the other jar where @Entity  
classes can be found

The <jar-file> technique can be tricky as paths are extremely  
unpredictable, file names change, some IDEs won't even build a jar  
till tests pass.  The <class> approach will definitely be the least  


View raw message