tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: OpenEJB doesn't select the persistence units based on classpath
Date Fri, 11 Sep 2009 21:26:41 GMT
We don't have that functionality now.  As far as I know, the "unit  
nameless" persistence ref only works when there is one unit in the  
entire application.  This is actually one of the things I wanted to  
fix for Java EE 6 -- that there is no way to specify the default when  
more than one unit exists.

Your case is a bit different in that as you point out we could make  
guess that the unit you want is the one in the same jar as your ejbs.   
We definitely do that when resolving ejb refs and I don't see any  
issues with adding the same logic for resolving presistence refs.

Probably something for 3.1.3 as we're down to the wire on 3.1.2.  Just  
a note as I know you're deploying into Geronimo.  You'll want to check  
the behavior there as Geronimo has it's own code for resolving  
persistence unit references.  It might be we need to add it in both  
places.

Created a JIRA for it:  https://issues.apache.org/jira/browse/OPENEJB-1072

-David


On Sep 11, 2009, at 10:39 AM, Quintin Beukes wrote:

> 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