tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Quintin Beukes <quin...@last.za.net>
Subject OpenEJB doesn't select the persistence units based on classpath
Date Fri, 11 Sep 2009 17:39:54 GMT
Hey,

If I have 2 jars, each with it's own persistence unit. Each of them
have entities and EJBs. Lets say it has the following setup:
KMSPlatform-ejb.jar has KMSPlatform-PU and SiteBean
KMS-Personnel-ejb.jar has KMS-Personnel-PU and PersonnelBean

So both Jars have an:
@PersistenceContext private EntityManager em;

When unit testing KMSPlatform-ejb it works fine.

But when unit testing KMS-Personnel-ejb, which has KMSPlatform-ejb on
it's classpath since the personnel jar depends on the platform jar, I
get the following failure. Not that since it's in the IDE they're
directories and not JARs. I can fix the problem by specifying the
persistence unit name in the @PersistenceContext annotation for each
container managed object (like EJBs).
1. Is there a way to have OpenEJB automatically detect the persistence
unit based on the classpath item it was found on.
2. Is there a way to have only one persistence unit in a single JAR,
and have other EJBs reference it. This seems to work fine, but then
the create-drop generation doesn't get applied for the other JARs. Any
way to get this?

Failure:
Apache OpenEJB 3.1.2-SNAPSHOT    build: 20090827-09:05
http://openejb.apache.org/
INFO - openejb.home = /home/quintin/dev/kms/KMSPlatform/KMS-Personnel-ejb
INFO - openejb.base = /home/quintin/dev/kms/KMSPlatform/KMS-Personnel-ejb
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=jdbc_kmsPool, type=Resource,
provider-id=Default JDBC Database)
INFO - Found ClientModule in classpath:
/opt/netbeans-6.7.1/java2/ant/lib/ant-launcher.jar
INFO - Found ClientModule in classpath:
/opt/netbeans-6.7.1/java2/ant/lib/ant.jar
INFO - Found ClientModule in classpath:
/home/quintin/dev/kms/KMSPlatform/ApplicationClientLib/dist/ApplicationClientLib.jar
INFO - Found ClientModule in classpath:
/home/quintin/dev/kms/libs/junit-openejb/xml-resolver-1.2.jar
INFO - Found EjbModule in classpath:
/home/quintin/dev/kms/KMSPlatform/KMSPlatform-ejb/dist/KMSPlatform-ejb.jar
INFO - Found ClientModule in classpath:
/home/quintin/dev/kms/libs/hibernate/javassist-3.9.0.GA.jar
INFO - Found EjbModule in classpath:
/home/quintin/dev/kms/KMSPlatform/UnitTesting/dist/UnitTesting.jar
INFO - Found EjbModule in classpath:
/home/quintin/dev/kms/KMSPlatform/KMS-Personnel-ejb/build/jar
INFO - Beginning load: /opt/netbeans-6.7.1/java2/ant/lib/ant-launcher.jar
INFO - Beginning load: /opt/netbeans-6.7.1/java2/ant/lib/ant.jar
INFO - Beginning load:
/home/quintin/dev/kms/KMSPlatform/ApplicationClientLib/dist/ApplicationClientLib.jar
INFO - Beginning load:
/home/quintin/dev/kms/libs/junit-openejb/xml-resolver-1.2.jar
INFO - Beginning load:
/home/quintin/dev/kms/KMSPlatform/KMSPlatform-ejb/dist/KMSPlatform-ejb.jar
INFO - Beginning load:
/home/quintin/dev/kms/libs/hibernate/javassist-3.9.0.GA.jar
INFO - Beginning load:
/home/quintin/dev/kms/KMSPlatform/UnitTesting/dist/UnitTesting.jar
INFO - Beginning load:
/home/quintin/dev/kms/KMSPlatform/KMS-Personnel-ejb/build/jar
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container,
type=Container, provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean SiteBean:
Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring PersistenceUnit(name=KMSPlatform-PU,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Auto-creating a Resource with id 'jdbc_kmsPoolNonJta' of type
'DataSource for 'KMSPlatform-PU'.
INFO - Configuring Service(id=jdbc_kmsPoolNonJta, type=Resource,
provider-id=jdbc_kmsPool)
INFO - Adjusting PersistenceUnit KMSPlatform-PU <jta-data-source> to
Resource ID 'jdbc_kmsPool' from 'jdbc/kmsPool'
INFO - Adjusting PersistenceUnit KMSPlatform-PU <non-jta-data-source>
to Resource ID 'jdbc_kmsPoolNonJta' from 'null'
INFO - Configuring PersistenceUnit(name=KMS-Personnel-PU,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting PersistenceUnit KMS-Personnel-PU <jta-data-source> to
Resource ID 'jdbc_kmsPool' from 'jdbc/kmsPool'
INFO - Adjusting PersistenceUnit KMS-Personnel-PU
<non-jta-data-source> to Resource ID 'jdbc_kmsPoolNonJta' from 'null'
ERROR - FAIL ... SiteBean:        Persistence unit not found for
@PersistenceContext(name="em", unitName="").  Available units
[KMS-Personnel-PU, KMSPlatform-PU]
ERROR - Invalid
EjbModule(path=/home/quintin/dev/kms/KMSPlatform/KMSPlatform-ejb/dist/KMSPlatform-ejb.jar)
ERROR - FAIL ... PersonnelBean:        Persistence unit not found for
@PersistenceContext(name="em", unitName="").  Available units
[KMS-Personnel-PU, KMSPlatform-PU]
ERROR - Invalid
EjbModule(path=/home/quintin/dev/kms/KMSPlatform/KMS-Personnel-ejb/build/jar)
INFO - Set the 'openejb.validation.output.level' system property to
VERBOSE for increased validation details.
WARN - Jar not loaded. classpath.ear.  Module failed validation.
AppModule(path=classpath.ear)

-- 
Quintin Beukes

Mime
View raw message