You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by hamtho <th...@project-team.de> on 2009/02/06 11:14:24 UTC

How to enable/disable Hibernate EntityManager

Hi,

I´m still struggling with the EXTENDED Persistence context and
EntityManager.
Maybe it has anything to do, because i use the Hibernate EntityManager.
But I´ve got the strange behaviour, that in one test case - which works
(!!!) - only the Hibernate-Session is loaded while openEJB starts up and in
the other test case - which does not work - the HibernateEntityManager is
used.
The persistence.xml is identical in both cases.

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
	<persistence-unit name="IisPU">
		<jta-data-source>gerdaDatabase</jta-data-source>
		 <non-jta-data-source>gerdaDatabaseUnmanaged</non-jta-data-source> 
		 <provider>org.hibernate.ejb.HibernatePersistence</provider>
		 
		<properties>
			<property name="hibernate.hbm2ddl.auto" value="update" />
			<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
		 <property name="hibernate.transaction.manager_lookup_class"
value="ch.bmw.service.DynamicTransactionManagerLookup"/>
		
		</properties>
	</persistence-unit>
</persistence>

Is there any chance to control wheater openEJB should use Hibernate or
HibernateEntityManager or what is the strategy of openEJB to decide which
implementation to load?

Maybe someone can help

Thomas
-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21869752.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: AW: Override PersistenceContext

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Thomas,

did you try something like that ?

<ejb-jar>
                <enterprise-beans>
                                                 
                               <session>
                                              
<ejb-name>myJar.jar#mypackage.MyManager</ejb-name>
                                              
<ejb-class>mypackage.impl.MyManagerImpl</ejb-class>
                                               <persistence-context-ref> 
                                                              
<persistence-context-ref-name>mypackage.impl.MyManagerImpl/em</persistence-context-ref-name>
                                              
<persistence-unit-name>PU</persistence-unit-name>
                                               </persistence-context-ref>
                               </session>
                               
                </enterprise-beans>
</ejb-jar>



Regards,
Jean-Louis


Thomas.TH.Hamacher wrote:
> 
> David,
> 
> any information on this?
> 
> Thomas
> 
> -----Ursprüngliche Nachricht-----
> Von: Thomas.TH.Hamacher@partner.bmw.ch
> [mailto:Thomas.TH.Hamacher@partner.bmw.ch]
> Gesendet: Montag, 23. Februar 2009 13:11
> An: users@openejb.apache.org
> Betreff: AW: Override PersistenceContext
> 
> David,
> 
> thanks so far. I tried the same thing and set up a simple test-project to
> play with the ejb-jar.xml My result is as follows:
> 
> Everything works as expected if I override the settings within the same
> jar. If I try to override the settings from the referenced jar, it does
> not work.
> Do you have any idea about this?
> 
> I had to adjust the ejb-jar.xml as follows, so that the entityManager is
> injected correctly.
> I use the ejb-jar.xml within my original project. The referenced jar only
> has an ejb-jar with an empty <ejb-jar />-tag
> 
> ----------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
>                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
>                 version="3.0"
>                 metadata-complete="true" >
> 
>         <enterprise-beans>
>                 <session>
>                         <ejb-name>CustomerManager2Impl</ejb-name>
>                        
> <business-local>company.CustomerManager2</business-local>
>                        
> <ejb-class>company.CustomerManager2Impl</ejb-class>
>                         <session-type>Stateless</session-type>
>                         <persistence-context-ref>
>                                
> <persistence-context-ref-name>em2</persistence-context-ref-name>
>                                
> <persistence-unit-name>IisTestPU2</persistence-unit-name>
>                                 <injection-target>
>                                        
> <injection-target-class>company.CustomerManager2Impl</injection-target-class>
>                                        
> <injection-target-name>em</injection-target-name>
>                                 </injection-target>
>                         </persistence-context-ref>
>                 </session>
> 
>                 <session>
>                         <ejb-name>CustomerManagerImpl</ejb-name>
>                        
> <business-local>company.CustomerManager</business-local>
>                         <ejb-class>company.CustomerManagerImpl</ejb-class>
>                         <session-type>Stateless</session-type>
>                         <persistence-context-ref>
>                                
> <persistence-context-ref-name>em</persistence-context-ref-name>
>                                
> <persistence-unit-name>IisTestPU</persistence-unit-name>
>                                 <injection-target>
>                                        
> <injection-target-class>company.CustomerManagerImpl</injection-target-class>
>                                        
> <injection-target-name>em</injection-target-name>
>                                 </injection-target>
>                         </persistence-context-ref>
>                 </session>
> 
>         </enterprise-beans>
> </ejb-jar>
> ----------------------------------------------------------------
> 
> So if I copy the CustomerManager2Impl into the same jar, everything works
> fine, but as soon as I copy this into another jar and reference this jar,
> the deployment does not work anymore.
> 
> Here comes the output:
> ----------------------------------------------------------------
> 2009-02-23 12:58:10,141  INFO OpenEJB.startup:70 - openejb.home =
> C:\01-development\06-workspace\simpleEjbTest
> 2009-02-23 12:58:10,141  INFO OpenEJB.startup:70 - openejb.base =
> C:\01-development\06-workspace\simpleEjbTest
> 2009-02-23 12:58:10,141 DEBUG OpenEJB.startup:82 - Instantiating assembler
> class org.apache.openejb.assembler.classic.Assembler
> 2009-02-23 12:58:10,953  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=Default Security Service, type=SecurityService,
> provider-id=Default Security Service)
> 2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=Default Transaction Manager, type=TransactionManager,
> provider-id=Default Transaction Manager)
> 2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My DataSource, type=Resource, provider-id=Default JDBC
> Database)
> 2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default
> JDBC Database)
> 2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My JMS Resource Adapter, type=Resource, provider-id=Default JMS
> Resource Adapter)
> 2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My JMS Connection Factory, type=Resource, provider-id=Default
> JMS Connection Factory)
> 2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=gerdaDatabaseUnmanaged, type=Resource, provider-id=Default JDBC
> Database)
> 2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=gerdaDatabase, type=Resource, provider-id=Default JDBC
> Database)
> 2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My CMP Container, type=Container, provider-id=Default CMP
> Container)
> 2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My BMP Container, type=Container, provider-id=Default BMP
> Container)
> 2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My Stateful Container, type=Container, provider-id=Default
> Stateful Container)
> 2009-02-23 12:58:11,000  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My Stateless Container, type=Container, provider-id=Default
> Stateless Container)
> 2009-02-23 12:58:11,000  INFO OpenEJB.startup.config:70 - Configuring
> Service(id=My MDB Container , type=Container, provider-id=Default MDB
> Container)
> 2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using
> openejb.deployments.classpath.include ''
> 2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using
> openejb.deployments.classpath.exclude '.*'
> 2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using
> openejb.deployments.classpath.filter.systemapps 'true'
> 2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using
> openejb.deployments.classpath.filter.descriptors 'false'
> 2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using
> openejb.deployments.classpath.require.descriptor 'false'
> 2009-02-23 12:58:11,109 DEBUG OpenEJB.startup.config:82 - Inspecting
> classpath for applications: 0 urls.
> 2009-02-23 12:58:11,234  INFO OpenEJB.startup.config:70 - Found EjbModule
> in classpath: C:\01-development\06-workspace\simpleEjbTest\target\classes
> 2009-02-23 12:58:11,344  INFO OpenEJB.startup.config:70 - Found EjbModule
> in classpath:
> C:\m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - URLs after
> filtering: 021
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: jar:file:/C:/m2repo/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: jar:file:/C:/m2repo/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> file:/C:/01-development/06-workspace/simpleEjbTest/target/test-classes/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: jar:file:/C:/m2repo/org/testng/testng/5.8/testng-5.8-jdk15.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/slf4j/slf4j-log4j12/1.5.3/slf4j-log4j12-1.5.3.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: file:/C:/01-development/06-workspace/simpleEjbTest/target/classes/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: jar:file:/C:/m2repo/antlr/antlr/2.7.6/antlr-2.7.6.jar!/
> 2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: jar:file:/C:/m2repo/org/slf4j/slf4j-api/1.5.3/slf4j-api-1.5.3.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/apache/openejb/asm-finder/3.1/asm-finder-3.1.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path: jar:file:/C:/m2repo/oro/oro/2.0.8/oro-2.0.8.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/apache/openejb/commons-dbcp-all/1.3-r699049/commons-dbcp-all-1.3-r699049.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/org/apache/maven/surefire/surefire-booter/2.4.3/surefire-booter-2.4.3.jar!/
> 2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors
> path:
> jar:file:/C:/m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar!/
> 2009-02-23 12:58:11,375  INFO OpenEJB.startup.config:70 - Beginning load:
> C:\01-development\06-workspace\simpleEjbTest\target\classes
> 2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file
> C:\01-development\06-workspace\simpleEjbTest\temp\AppModule-49923
> 2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file
> C:\01-development\06-workspace\simpleEjbTest\temp\CustomerManager2Impl-1.0.0-SNAPSHOT-49922.jar
> 2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file
> C:\01-development\06-workspace\simpleEjbTest\temp
> 2009-02-23 12:58:11,391  INFO OpenEJB:70 - AntiJarLocking enabled. Using
> URL cache dir C:\01-development\06-workspace\simpleEjbTest\temp
> 2009-02-23 12:58:12,203 DEBUG OpenEJB:82 - Destroying classLoader
> URLClassLoader@7461949
> 2009-02-23 12:58:12,234  INFO OpenEJB.startup.config:70 - Beginning load:
> C:\m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar
> 2009-02-23 12:58:12,266 DEBUG OpenEJB:82 - Coppied jar file to
> C:\01-development\06-workspace\simpleEjbTest\temp\CustomerManager2Impl-1.0.0-SNAPSHOT-38725.jar
> 2009-02-23 12:58:12,281 DEBUG OpenEJB:82 - Destroying classLoader
> URLClassLoader@6427893
> 2009-02-23 12:58:12,281  INFO OpenEJB.startup.config:70 - Configuring
> enterprise application: classpath.ear
> 2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb
> CustomerManager2Impl: EjbDeployment(deployment-id=CustomerManager2Impl)
> 2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb
> CustomerManagerImpl: EjbDeployment(deployment-id=CustomerManagerImpl)
> 2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb
> CustomerManager2Impl: EjbDeployment(deployment-id=CustomerManager2Impl)
> 2009-02-23 12:58:12,703  INFO OpenEJB.startup.config:70 - Configuring
> PersistenceUnit(name=IisTestPU,
> provider=org.hibernate.ejb.HibernatePersistence)
> 2009-02-23 12:58:12,703  INFO OpenEJB.startup.config:70 - Configuring
> PersistenceUnit(name=IisTestPU2,
> provider=org.hibernate.ejb.HibernatePersistence)
> 2009-02-23 12:58:12,719 DEBUG OpenEJB.startup.config:82 - Adjusting
> PersistenceUnit(name=IisTestPU) property to
> hibernate.transaction.manager_lookup_class=org.apache.openejb.hibernate.TransactionManagerLookup
> 2009-02-23 12:58:12,719 DEBUG OpenEJB.startup.config:82 - Adjusting
> PersistenceUnit(name=IisTestPU2) property to
> hibernate.transaction.manager_lookup_class=org.apache.openejb.hibernate.TransactionManagerLookup
> 2009-02-23 12:58:12,734 ERROR OpenEJB.startup.validation:46 - FAIL ...
> CustomerManager2Impl:    Persistence unit not found for
> @PersistenceContext(name="em", unitName="").  Available units [IisTestPU,
> IisTestPU2]
> ----------------------------------------------------------------
> 
> 
> So do you have any idea what to do or what I missed here?
> 
> Thanks in advance
> 
> Thomas
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: David Blevins [mailto:david.blevins@visi.com]
> Gesendet: Freitag, 20. Februar 2009 08:46
> An: users@openejb.apache.org
> Betreff: Re: Override PersistenceContext
> 
> 
> On Feb 16, 2009, at 5:13 AM, <Th...@partner.bmw.ch>
> <Thomas.TH.Hamacher@partner.bmw.ch
>  > wrote:
> 
>> Hi @all,
>>
>> I´d like to override the settings for the PersistenceContext, but
>> somehow it does not work.
>> My Scenario is as follows: I´ve got a REFERENCED JAR and my local
>> project. The referenced jar contains some stateless services, with an
>> annotated EntityManager pointing to the default PersistenceContext
>> without declaring a unitName.
>>
>> Then I´ve got my project, which also has it´s own persistence.xml and
>> some services. As there are 2 persistence-units-defintions now, the
>> services from the referenced as well as those from my local project
>> fail to start, because injection does not work anymore. So far so
>> good! So I decided to override the persistenceUnit from the services
>> in the referencedJar and point them to a specific
>> persistence-unit-name.
>>
> 
> The override looks perfect and I hacked up a test case to verify the
> overriding occurs as expected and all was fine.  So there must be
> something else going on here.
> 
> When we process annotations we actually update the descriptor that comes
> with the application and it is possible to set a flag so that it will be
> written back to disk allowing you to see the final and definitive set of
> metadata.  Set the 'openejb.descriptors.output' flag to 'true' and scan
> the log output for the paths to the update ejb- jar.xml file(s).
> 
> If what is going on doesn't become obvious, post the log output as well as
> the generated ejb-jar.xml.
> 
> -David
> 
> 
>>
>> This is my business class from the referenced jar (where
>> CustomerManager is it´s local interface annotated with @Local):
>> ----------------------------------------------------------------------
>> -------
>> package company;
>>
>> @Stateless
>> public class CustomerManagerImpl implements CustomerManager {
>>
>> ...
>>        @PersistenceContext
>>        private EntityManager entityManager; ...
>> }
>>
>> ----------------------------------------------------------------------
>> -------
>>
>> Now I included an ejb-jar.xml in my /classes/META-INF directory within
>> my local project and redefined the EntityManager as follows:
>>
>>
>> ----------------------------------------------------------------------
>> ------- <?xml version="1.0" encoding="UTF-8"?> <ejb-jar
>> xmlns="http://java.sun.com/xml/ns/javaee"
>>                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
>> "
>>                version="3.0"
>>                metadata-complete="true" >
>>        <enterprise-beans>
>>                <session>
>>                        <ejb-name>CustomerManagerImpl</ejb-name>
>>                        <business-local>company.CustomerManager</
>> business-local>
>>                        <ejb-class>company.CustomerManagerImpl</ejb-
>> class>
>>                        <session-type>Stateless</session-type>
>>                        <persistence-context-ref>
>>                                <persistence-context-ref-
>> name>company.CustomerManagerImpl/entityManager</persistence-context-
>> ref-name>
>>                                <persistence-unit-name>IisTestPU</
>> persistence-unit-name>
>>                        </persistence-context-ref>
>>                </session>
>>        </enterprise-beans>
>> </ejb-jar>
>> ----------------------------------------------------------------------
>> -------
>>
>> If I put anything wrong in this ejb-jar.xml I always receive an error.
>> So I assume, that the ejb-jar is interpreted correctly, but anyways I
>> receive an error when booting openEJB.
>>
>> ERROR - FAIL ... CustomerManagerImpl:   The persistence unit "" does
>> not exist.  Update the "entityManager" PersistenceContext ref to one
>> of the avail able units [CleoServicePU, IisTestPU] or declare the unit
>> in a persistence.xml like the following:<persistence
>> xmlns="http://java.sun.com/xml/ns/persi
>> stence" version="1.0"><persistence-unit name=""><jta-data-
>> source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-
>> data-source>java:openejb
>> /Resource/myUnmanagedDataSource</non-jta-data-
>> source><properties><property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true
>> )"/></properties></persistence-unit></persistence>
>>
>>
>> Did I miss anything?
>>
>> Thomas
>>
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p22288917.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


AW: Override PersistenceContext

Posted by Th...@partner.bmw.ch.
David,

any information on this?

Thomas

-----Ursprüngliche Nachricht-----
Von: Thomas.TH.Hamacher@partner.bmw.ch [mailto:Thomas.TH.Hamacher@partner.bmw.ch]
Gesendet: Montag, 23. Februar 2009 13:11
An: users@openejb.apache.org
Betreff: AW: Override PersistenceContext

David,

thanks so far. I tried the same thing and set up a simple test-project to play with the ejb-jar.xml My result is as follows:

Everything works as expected if I override the settings within the same jar. If I try to override the settings from the referenced jar, it does not work.
Do you have any idea about this?

I had to adjust the ejb-jar.xml as follows, so that the entityManager is injected correctly.
I use the ejb-jar.xml within my original project. The referenced jar only has an ejb-jar with an empty <ejb-jar />-tag

----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
                version="3.0"
                metadata-complete="true" >

        <enterprise-beans>
                <session>
                        <ejb-name>CustomerManager2Impl</ejb-name>
                        <business-local>company.CustomerManager2</business-local>
                        <ejb-class>company.CustomerManager2Impl</ejb-class>
                        <session-type>Stateless</session-type>
                        <persistence-context-ref>
                                <persistence-context-ref-name>em2</persistence-context-ref-name>
                                <persistence-unit-name>IisTestPU2</persistence-unit-name>
                                <injection-target>
                                        <injection-target-class>company.CustomerManager2Impl</injection-target-class>
                                        <injection-target-name>em</injection-target-name>
                                </injection-target>
                        </persistence-context-ref>
                </session>

                <session>
                        <ejb-name>CustomerManagerImpl</ejb-name>
                        <business-local>company.CustomerManager</business-local>
                        <ejb-class>company.CustomerManagerImpl</ejb-class>
                        <session-type>Stateless</session-type>
                        <persistence-context-ref>
                                <persistence-context-ref-name>em</persistence-context-ref-name>
                                <persistence-unit-name>IisTestPU</persistence-unit-name>
                                <injection-target>
                                        <injection-target-class>company.CustomerManagerImpl</injection-target-class>
                                        <injection-target-name>em</injection-target-name>
                                </injection-target>
                        </persistence-context-ref>
                </session>

        </enterprise-beans>
</ejb-jar>
----------------------------------------------------------------

So if I copy the CustomerManager2Impl into the same jar, everything works fine, but as soon as I copy this into another jar and reference this jar, the deployment does not work anymore.

Here comes the output:
----------------------------------------------------------------
2009-02-23 12:58:10,141  INFO OpenEJB.startup:70 - openejb.home = C:\01-development\06-workspace\simpleEjbTest
2009-02-23 12:58:10,141  INFO OpenEJB.startup:70 - openejb.base = C:\01-development\06-workspace\simpleEjbTest
2009-02-23 12:58:10,141 DEBUG OpenEJB.startup:82 - Instantiating assembler class org.apache.openejb.assembler.classic.Assembler
2009-02-23 12:58:10,953  INFO OpenEJB.startup.config:70 - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=gerdaDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=gerdaDatabase, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=My CMP Container, type=Container, provider-id=Default CMP Container)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=My BMP Container, type=Container, provider-id=Default BMP Container)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container)
2009-02-23 12:58:11,000  INFO OpenEJB.startup.config:70 - Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container)
2009-02-23 12:58:11,000  INFO OpenEJB.startup.config:70 - Configuring Service(id=My MDB Container , type=Container, provider-id=Default MDB Container)
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.include ''
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.exclude '.*'
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.filter.systemapps 'true'
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.filter.descriptors 'false'
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.require.descriptor 'false'
2009-02-23 12:58:11,109 DEBUG OpenEJB.startup.config:82 - Inspecting classpath for applications: 0 urls.
2009-02-23 12:58:11,234  INFO OpenEJB.startup.config:70 - Found EjbModule in classpath: C:\01-development\06-workspace\simpleEjbTest\target\classes
2009-02-23 12:58:11,344  INFO OpenEJB.startup.config:70 - Found EjbModule in classpath: C:\m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - URLs after filtering: 021
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: file:/C:/01-development/06-workspace/simpleEjbTest/target/test-classes/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/testng/testng/5.8/testng-5.8-jdk15.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/slf4j/slf4j-log4j12/1.5.3/slf4j-log4j12-1.5.3.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: file:/C:/01-development/06-workspace/simpleEjbTest/target/classes/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/antlr/antlr/2.7.6/antlr-2.7.6.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/slf4j/slf4j-api/1.5.3/slf4j-api-1.5.3.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/openejb/asm-finder/3.1/asm-finder-3.1.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/oro/oro/2.0.8/oro-2.0.8.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/openejb/commons-dbcp-all/1.3-r699049/commons-dbcp-all-1.3-r699049.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/maven/surefire/surefire-booter/2.4.3/surefire-booter-2.4.3.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar!/
2009-02-23 12:58:11,375  INFO OpenEJB.startup.config:70 - Beginning load: C:\01-development\06-workspace\simpleEjbTest\target\classes
2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file C:\01-development\06-workspace\simpleEjbTest\temp\AppModule-49923
2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file C:\01-development\06-workspace\simpleEjbTest\temp\CustomerManager2Impl-1.0.0-SNAPSHOT-49922.jar
2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file C:\01-development\06-workspace\simpleEjbTest\temp
2009-02-23 12:58:11,391  INFO OpenEJB:70 - AntiJarLocking enabled. Using URL cache dir C:\01-development\06-workspace\simpleEjbTest\temp
2009-02-23 12:58:12,203 DEBUG OpenEJB:82 - Destroying classLoader URLClassLoader@7461949
2009-02-23 12:58:12,234  INFO OpenEJB.startup.config:70 - Beginning load: C:\m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar
2009-02-23 12:58:12,266 DEBUG OpenEJB:82 - Coppied jar file to C:\01-development\06-workspace\simpleEjbTest\temp\CustomerManager2Impl-1.0.0-SNAPSHOT-38725.jar
2009-02-23 12:58:12,281 DEBUG OpenEJB:82 - Destroying classLoader URLClassLoader@6427893
2009-02-23 12:58:12,281  INFO OpenEJB.startup.config:70 - Configuring enterprise application: classpath.ear
2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb CustomerManager2Impl: EjbDeployment(deployment-id=CustomerManager2Impl)
2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb CustomerManagerImpl: EjbDeployment(deployment-id=CustomerManagerImpl)
2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb CustomerManager2Impl: EjbDeployment(deployment-id=CustomerManager2Impl)
2009-02-23 12:58:12,703  INFO OpenEJB.startup.config:70 - Configuring PersistenceUnit(name=IisTestPU, provider=org.hibernate.ejb.HibernatePersistence)
2009-02-23 12:58:12,703  INFO OpenEJB.startup.config:70 - Configuring PersistenceUnit(name=IisTestPU2, provider=org.hibernate.ejb.HibernatePersistence)
2009-02-23 12:58:12,719 DEBUG OpenEJB.startup.config:82 - Adjusting PersistenceUnit(name=IisTestPU) property to hibernate.transaction.manager_lookup_class=org.apache.openejb.hibernate.TransactionManagerLookup
2009-02-23 12:58:12,719 DEBUG OpenEJB.startup.config:82 - Adjusting PersistenceUnit(name=IisTestPU2) property to hibernate.transaction.manager_lookup_class=org.apache.openejb.hibernate.TransactionManagerLookup
2009-02-23 12:58:12,734 ERROR OpenEJB.startup.validation:46 - FAIL ... CustomerManager2Impl:    Persistence unit not found for @PersistenceContext(name="em", unitName="").  Available units [IisTestPU, IisTestPU2]
----------------------------------------------------------------


So do you have any idea what to do or what I missed here?

Thanks in advance

Thomas



-----Ursprüngliche Nachricht-----
Von: David Blevins [mailto:david.blevins@visi.com]
Gesendet: Freitag, 20. Februar 2009 08:46
An: users@openejb.apache.org
Betreff: Re: Override PersistenceContext


On Feb 16, 2009, at 5:13 AM, <Th...@partner.bmw.ch> <Thomas.TH.Hamacher@partner.bmw.ch
 > wrote:

> Hi @all,
>
> I´d like to override the settings for the PersistenceContext, but
> somehow it does not work.
> My Scenario is as follows: I´ve got a REFERENCED JAR and my local
> project. The referenced jar contains some stateless services, with an
> annotated EntityManager pointing to the default PersistenceContext
> without declaring a unitName.
>
> Then I´ve got my project, which also has it´s own persistence.xml and
> some services. As there are 2 persistence-units-defintions now, the
> services from the referenced as well as those from my local project
> fail to start, because injection does not work anymore. So far so
> good! So I decided to override the persistenceUnit from the services
> in the referencedJar and point them to a specific
> persistence-unit-name.
>

The override looks perfect and I hacked up a test case to verify the overriding occurs as expected and all was fine.  So there must be something else going on here.

When we process annotations we actually update the descriptor that comes with the application and it is possible to set a flag so that it will be written back to disk allowing you to see the final and definitive set of metadata.  Set the 'openejb.descriptors.output' flag to 'true' and scan the log output for the paths to the update ejb- jar.xml file(s).

If what is going on doesn't become obvious, post the log output as well as the generated ejb-jar.xml.

-David


>
> This is my business class from the referenced jar (where
> CustomerManager is it´s local interface annotated with @Local):
> ----------------------------------------------------------------------
> -------
> package company;
>
> @Stateless
> public class CustomerManagerImpl implements CustomerManager {
>
> ...
>        @PersistenceContext
>        private EntityManager entityManager; ...
> }
>
> ----------------------------------------------------------------------
> -------
>
> Now I included an ejb-jar.xml in my /classes/META-INF directory within
> my local project and redefined the EntityManager as follows:
>
>
> ----------------------------------------------------------------------
> ------- <?xml version="1.0" encoding="UTF-8"?> <ejb-jar
> xmlns="http://java.sun.com/xml/ns/javaee"
>                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
> "
>                version="3.0"
>                metadata-complete="true" >
>        <enterprise-beans>
>                <session>
>                        <ejb-name>CustomerManagerImpl</ejb-name>
>                        <business-local>company.CustomerManager</
> business-local>
>                        <ejb-class>company.CustomerManagerImpl</ejb-
> class>
>                        <session-type>Stateless</session-type>
>                        <persistence-context-ref>
>                                <persistence-context-ref-
> name>company.CustomerManagerImpl/entityManager</persistence-context-
> ref-name>
>                                <persistence-unit-name>IisTestPU</
> persistence-unit-name>
>                        </persistence-context-ref>
>                </session>
>        </enterprise-beans>
> </ejb-jar>
> ----------------------------------------------------------------------
> -------
>
> If I put anything wrong in this ejb-jar.xml I always receive an error.
> So I assume, that the ejb-jar is interpreted correctly, but anyways I
> receive an error when booting openEJB.
>
> ERROR - FAIL ... CustomerManagerImpl:   The persistence unit "" does
> not exist.  Update the "entityManager" PersistenceContext ref to one
> of the avail able units [CleoServicePU, IisTestPU] or declare the unit
> in a persistence.xml like the following:<persistence
> xmlns="http://java.sun.com/xml/ns/persi
> stence" version="1.0"><persistence-unit name=""><jta-data-
> source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-
> data-source>java:openejb
> /Resource/myUnmanagedDataSource</non-jta-data-
> source><properties><property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true
> )"/></properties></persistence-unit></persistence>
>
>
> Did I miss anything?
>
> Thomas
>




Re: AW: AW: Override PersistenceContext

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.

Thomas.TH.Hamacher wrote:
> 
> @Jean-Louis: No - I have not tried it yet - this might be an idea. I´ll
> let you know as soon as I tested it.
> 

Thomas,

I had the same requirement and it worked for me with OpenEJB.
So good luck ;-)

Jean-Louis
-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p22304766.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: AW: AW: Override PersistenceContext

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.

Thomas.TH.Hamacher wrote:
> 
> @Jean-Louis: No - I have not tried it yet - this might be an idea. I´ll
> let you know as soon as I tested it.
> 

Thomas,

I had the same requirement and it worked for me with OpenEJB.
So good luck ;-)

Jean-Louis
-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p22304771.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


AW: AW: Override PersistenceContext

Posted by Th...@partner.bmw.ch.
David,

thanks for your answer.
Actually the background for the ejb-jar.xml definition is as follows:
I´ve got a common project, that is used together with some other projects within different persistence-units.
Therefore the EntityManager is not bound to a specific persistenceUnit, but the annotation is simply left empty.
During the deployment (in my case in the ear, which is deployed to a JBoss AS) the binding of this specific EntityManager to a specific persistenceUnit is done.
During my tests with openEJB I run into the problem, that I have multiple persistence.xml on my classpath and therefore the EntityManager has to be bound to a specific persistenceUnit as well. Unfortunately I cannot bind it through your recommondation using the alternate DD, as the persistenceUnit changes with whatever project uses this common library and the EntityManager should join the project´s persistenceUnit.

Do you understand, what I mean?

@Jean-Louis: No - I have not tried it yet - this might be an idea. I´ll let you know as soon as I tested it.

Thomas

-----Ursprüngliche Nachricht-----
Von: David Blevins [mailto:david.blevins@visi.com]
Gesendet: Dienstag, 3. März 2009 04:26
An: users@openejb.apache.org
Betreff: Re: AW: Override PersistenceContext

On Feb 23, 2009, at 4:11 AM, <Th...@partner.bmw.ch> <Thomas.TH.Hamacher@partner.bmw.ch
 > wrote:

> So if I copy the CustomerManager2Impl into the same jar, everything
> works fine, but as soon as I copy this into another jar and reference
> this jar, the deployment does not work anymore.

Hmm.  The ejb-jar.xml has to be in the module.  I suspect that you have it outside the module because you don't want that particular ejb- jar.xml data to be picked up at runtime by the production ejb container.  If that's the case, some of the code we have in trunk might help.

There was a post about it a couple weeks ago.  I've taken that email and cleaned it up for you:

   http://cwiki.apache.org/OPENEJBx30/alternate-descriptors.html

If you use maven, there are 3.1.1 snapshots available here:

   http://people.apache.org/repo/m2-snapshot-repository/org/apache/openejb/

If you want an openejb.zip file I'd be happy to build one for you.

-David





Re: AW: Override PersistenceContext

Posted by David Blevins <da...@visi.com>.
On Feb 23, 2009, at 4:11 AM, <Th...@partner.bmw.ch> <Thomas.TH.Hamacher@partner.bmw.ch 
 > wrote:

> So if I copy the CustomerManager2Impl into the same jar, everything  
> works fine, but as soon as I copy this into another jar and  
> reference this jar, the deployment does not work anymore.

Hmm.  The ejb-jar.xml has to be in the module.  I suspect that you  
have it outside the module because you don't want that particular ejb- 
jar.xml data to be picked up at runtime by the production ejb  
container.  If that's the case, some of the code we have in trunk  
might help.

There was a post about it a couple weeks ago.  I've taken that email  
and cleaned it up for you:

   http://cwiki.apache.org/OPENEJBx30/alternate-descriptors.html

If you use maven, there are 3.1.1 snapshots available here:

   http://people.apache.org/repo/m2-snapshot-repository/org/apache/openejb/

If you want an openejb.zip file I'd be happy to build one for you.

-David




AW: Override PersistenceContext

Posted by Th...@partner.bmw.ch.
David,

thanks so far. I tried the same thing and set up a simple test-project to play with the ejb-jar.xml
My result is as follows:

Everything works as expected if I override the settings within the same jar. If I try to override the settings from the referenced jar, it does not work.
Do you have any idea about this?

I had to adjust the ejb-jar.xml as follows, so that the entityManager is injected correctly.
I use the ejb-jar.xml within my original project. The referenced jar only has an ejb-jar with an empty <ejb-jar />-tag

----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
                version="3.0"
                metadata-complete="true" >

        <enterprise-beans>
                <session>
                        <ejb-name>CustomerManager2Impl</ejb-name>
                        <business-local>company.CustomerManager2</business-local>
                        <ejb-class>company.CustomerManager2Impl</ejb-class>
                        <session-type>Stateless</session-type>
                        <persistence-context-ref>
                                <persistence-context-ref-name>em2</persistence-context-ref-name>
                                <persistence-unit-name>IisTestPU2</persistence-unit-name>
                                <injection-target>
                                        <injection-target-class>company.CustomerManager2Impl</injection-target-class>
                                        <injection-target-name>em</injection-target-name>
                                </injection-target>
                        </persistence-context-ref>
                </session>

                <session>
                        <ejb-name>CustomerManagerImpl</ejb-name>
                        <business-local>company.CustomerManager</business-local>
                        <ejb-class>company.CustomerManagerImpl</ejb-class>
                        <session-type>Stateless</session-type>
                        <persistence-context-ref>
                                <persistence-context-ref-name>em</persistence-context-ref-name>
                                <persistence-unit-name>IisTestPU</persistence-unit-name>
                                <injection-target>
                                        <injection-target-class>company.CustomerManagerImpl</injection-target-class>
                                        <injection-target-name>em</injection-target-name>
                                </injection-target>
                        </persistence-context-ref>
                </session>

        </enterprise-beans>
</ejb-jar>
----------------------------------------------------------------

So if I copy the CustomerManager2Impl into the same jar, everything works fine, but as soon as I copy this into another jar and reference this jar, the deployment does not work anymore.

Here comes the output:
----------------------------------------------------------------
2009-02-23 12:58:10,141  INFO OpenEJB.startup:70 - openejb.home = C:\01-development\06-workspace\simpleEjbTest
2009-02-23 12:58:10,141  INFO OpenEJB.startup:70 - openejb.base = C:\01-development\06-workspace\simpleEjbTest
2009-02-23 12:58:10,141 DEBUG OpenEJB.startup:82 - Instantiating assembler class org.apache.openejb.assembler.classic.Assembler
2009-02-23 12:58:10,953  INFO OpenEJB.startup.config:70 - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
2009-02-23 12:58:10,969  INFO OpenEJB.startup.config:70 - Configuring Service(id=My JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=gerdaDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=gerdaDatabase, type=Resource, provider-id=Default JDBC Database)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=My CMP Container, type=Container, provider-id=Default CMP Container)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=My BMP Container, type=Container, provider-id=Default BMP Container)
2009-02-23 12:58:10,984  INFO OpenEJB.startup.config:70 - Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container)
2009-02-23 12:58:11,000  INFO OpenEJB.startup.config:70 - Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container)
2009-02-23 12:58:11,000  INFO OpenEJB.startup.config:70 - Configuring Service(id=My MDB Container , type=Container, provider-id=Default MDB Container)
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.include ''
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.exclude '.*'
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.filter.systemapps 'true'
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.filter.descriptors 'false'
2009-02-23 12:58:11,000 DEBUG OpenEJB.startup.config:82 - Using openejb.deployments.classpath.require.descriptor 'false'
2009-02-23 12:58:11,109 DEBUG OpenEJB.startup.config:82 - Inspecting classpath for applications: 0 urls.
2009-02-23 12:58:11,234  INFO OpenEJB.startup.config:70 - Found EjbModule in classpath: C:\01-development\06-workspace\simpleEjbTest\target\classes
2009-02-23 12:58:11,344  INFO OpenEJB.startup.config:70 - Found EjbModule in classpath: C:\m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - URLs after filtering: 021
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: file:/C:/01-development/06-workspace/simpleEjbTest/target/test-classes/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/testng/testng/5.8/testng-5.8-jdk15.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/slf4j/slf4j-log4j12/1.5.3/slf4j-log4j12-1.5.3.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: file:/C:/01-development/06-workspace/simpleEjbTest/target/classes/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/antlr/antlr/2.7.6/antlr-2.7.6.jar!/
2009-02-23 12:58:11,359 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/slf4j/slf4j-api/1.5.3/slf4j-api-1.5.3.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/openejb/asm-finder/3.1/asm-finder-3.1.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/oro/oro/2.0.8/oro-2.0.8.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/openejb/commons-dbcp-all/1.3-r699049/commons-dbcp-all-1.3-r699049.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/org/apache/maven/surefire/surefire-booter/2.4.3/surefire-booter-2.4.3.jar!/
2009-02-23 12:58:11,375 DEBUG OpenEJB.startup.config:82 - Descriptors path: jar:file:/C:/m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar!/
2009-02-23 12:58:11,375  INFO OpenEJB.startup.config:70 - Beginning load: C:\01-development\06-workspace\simpleEjbTest\target\classes
2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file C:\01-development\06-workspace\simpleEjbTest\temp\AppModule-49923
2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file C:\01-development\06-workspace\simpleEjbTest\temp\CustomerManager2Impl-1.0.0-SNAPSHOT-49922.jar
2009-02-23 12:58:11,391 DEBUG OpenEJB:82 - Deleted file C:\01-development\06-workspace\simpleEjbTest\temp
2009-02-23 12:58:11,391  INFO OpenEJB:70 - AntiJarLocking enabled. Using URL cache dir C:\01-development\06-workspace\simpleEjbTest\temp
2009-02-23 12:58:12,203 DEBUG OpenEJB:82 - Destroying classLoader URLClassLoader@7461949
2009-02-23 12:58:12,234  INFO OpenEJB.startup.config:70 - Beginning load: C:\m2repo/test/1.0.0-SNAPSHOT/CustomerManager2Impl-1.0.0-SNAPSHOT.jar
2009-02-23 12:58:12,266 DEBUG OpenEJB:82 - Coppied jar file to C:\01-development\06-workspace\simpleEjbTest\temp\CustomerManager2Impl-1.0.0-SNAPSHOT-38725.jar
2009-02-23 12:58:12,281 DEBUG OpenEJB:82 - Destroying classLoader URLClassLoader@6427893
2009-02-23 12:58:12,281  INFO OpenEJB.startup.config:70 - Configuring enterprise application: classpath.ear
2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb CustomerManager2Impl: EjbDeployment(deployment-id=CustomerManager2Impl)
2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb CustomerManagerImpl: EjbDeployment(deployment-id=CustomerManagerImpl)
2009-02-23 12:58:12,687  INFO OpenEJB:70 - Auto-deploying ejb CustomerManager2Impl: EjbDeployment(deployment-id=CustomerManager2Impl)
2009-02-23 12:58:12,703  INFO OpenEJB.startup.config:70 - Configuring PersistenceUnit(name=IisTestPU, provider=org.hibernate.ejb.HibernatePersistence)
2009-02-23 12:58:12,703  INFO OpenEJB.startup.config:70 - Configuring PersistenceUnit(name=IisTestPU2, provider=org.hibernate.ejb.HibernatePersistence)
2009-02-23 12:58:12,719 DEBUG OpenEJB.startup.config:82 - Adjusting PersistenceUnit(name=IisTestPU) property to hibernate.transaction.manager_lookup_class=org.apache.openejb.hibernate.TransactionManagerLookup
2009-02-23 12:58:12,719 DEBUG OpenEJB.startup.config:82 - Adjusting PersistenceUnit(name=IisTestPU2) property to hibernate.transaction.manager_lookup_class=org.apache.openejb.hibernate.TransactionManagerLookup
2009-02-23 12:58:12,734 ERROR OpenEJB.startup.validation:46 - FAIL ... CustomerManager2Impl:    Persistence unit not found for @PersistenceContext(name="em", unitName="").  Available units [IisTestPU, IisTestPU2]
----------------------------------------------------------------


So do you have any idea what to do or what I missed here?

Thanks in advance

Thomas



-----Ursprüngliche Nachricht-----
Von: David Blevins [mailto:david.blevins@visi.com]
Gesendet: Freitag, 20. Februar 2009 08:46
An: users@openejb.apache.org
Betreff: Re: Override PersistenceContext


On Feb 16, 2009, at 5:13 AM, <Th...@partner.bmw.ch> <Thomas.TH.Hamacher@partner.bmw.ch
 > wrote:

> Hi @all,
>
> I´d like to override the settings for the PersistenceContext, but
> somehow it does not work.
> My Scenario is as follows: I´ve got a REFERENCED JAR and my local
> project. The referenced jar contains some stateless services, with an
> annotated EntityManager pointing to the default PersistenceContext
> without declaring a unitName.
>
> Then I´ve got my project, which also has it´s own persistence.xml and
> some services. As there are 2 persistence-units-defintions now, the
> services from the referenced as well as those from my local project
> fail to start, because injection does not work anymore. So far so
> good! So I decided to override the persistenceUnit from the services
> in the referencedJar and point them to a specific
> persistence-unit-name.
>

The override looks perfect and I hacked up a test case to verify the overriding occurs as expected and all was fine.  So there must be something else going on here.

When we process annotations we actually update the descriptor that comes with the application and it is possible to set a flag so that it will be written back to disk allowing you to see the final and definitive set of metadata.  Set the 'openejb.descriptors.output' flag to 'true' and scan the log output for the paths to the update ejb- jar.xml file(s).

If what is going on doesn't become obvious, post the log output as well as the generated ejb-jar.xml.

-David


>
> This is my business class from the referenced jar (where
> CustomerManager is it´s local interface annotated with @Local):
> ----------------------------------------------------------------------
> -------
> package company;
>
> @Stateless
> public class CustomerManagerImpl implements CustomerManager {
>
> ...
>        @PersistenceContext
>        private EntityManager entityManager; ...
> }
>
> ----------------------------------------------------------------------
> -------
>
> Now I included an ejb-jar.xml in my /classes/META-INF directory within
> my local project and redefined the EntityManager as follows:
>
>
> ----------------------------------------------------------------------
> ------- <?xml version="1.0" encoding="UTF-8"?> <ejb-jar
> xmlns="http://java.sun.com/xml/ns/javaee"
>                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
> "
>                version="3.0"
>                metadata-complete="true" >
>        <enterprise-beans>
>                <session>
>                        <ejb-name>CustomerManagerImpl</ejb-name>
>                        <business-local>company.CustomerManager</
> business-local>
>                        <ejb-class>company.CustomerManagerImpl</ejb-
> class>
>                        <session-type>Stateless</session-type>
>                        <persistence-context-ref>
>                                <persistence-context-ref-
> name>company.CustomerManagerImpl/entityManager</persistence-context-
> ref-name>
>                                <persistence-unit-name>IisTestPU</
> persistence-unit-name>
>                        </persistence-context-ref>
>                </session>
>        </enterprise-beans>
> </ejb-jar>
> ----------------------------------------------------------------------
> -------
>
> If I put anything wrong in this ejb-jar.xml I always receive an error.
> So I assume, that the ejb-jar is interpreted correctly, but anyways I
> receive an error when booting openEJB.
>
> ERROR - FAIL ... CustomerManagerImpl:   The persistence unit "" does
> not exist.  Update the "entityManager" PersistenceContext ref to one
> of the avail able units [CleoServicePU, IisTestPU] or declare the unit
> in a persistence.xml like the following:<persistence
> xmlns="http://java.sun.com/xml/ns/persi
> stence" version="1.0"><persistence-unit name=""><jta-data-
> source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-
> data-source>java:openejb
> /Resource/myUnmanagedDataSource</non-jta-data-
> source><properties><property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true
> )"/></properties></persistence-unit></persistence>
>
>
> Did I miss anything?
>
> Thomas
>



Re: Override PersistenceContext

Posted by David Blevins <da...@visi.com>.
On Feb 16, 2009, at 5:13 AM, <Th...@partner.bmw.ch> <Thomas.TH.Hamacher@partner.bmw.ch 
 > wrote:

> Hi @all,
>
> I´d like to override the settings for the PersistenceContext, but  
> somehow it does not work.
> My Scenario is as follows: I´ve got a REFERENCED JAR and my local  
> project. The referenced jar contains some stateless services, with  
> an annotated EntityManager pointing to the default  
> PersistenceContext without declaring a unitName.
>
> Then I´ve got my project, which also has it´s own persistence.xml  
> and some services. As there are 2 persistence-units-defintions now,  
> the services from the referenced as well as those from my local  
> project fail to start, because injection does not work anymore. So  
> far so good! So I decided to override the persistenceUnit from the  
> services in the referencedJar and point them to a specific  
> persistence-unit-name.
>

The override looks perfect and I hacked up a test case to verify the  
overriding occurs as expected and all was fine.  So there must be  
something else going on here.

When we process annotations we actually update the descriptor that  
comes with the application and it is possible to set a flag so that it  
will be written back to disk allowing you to see the final and  
definitive set of metadata.  Set the 'openejb.descriptors.output' flag  
to 'true' and scan the log output for the paths to the update ejb- 
jar.xml file(s).

If what is going on doesn't become obvious, post the log output as  
well as the generated ejb-jar.xml.

-David


>
> This is my business class from the referenced jar (where  
> CustomerManager is it´s local interface annotated with @Local):
> -----------------------------------------------------------------------------
> package company;
>
> @Stateless
> public class CustomerManagerImpl implements CustomerManager {
>
> ...
>        @PersistenceContext
>        private EntityManager entityManager;
> ...
> }
>
> -----------------------------------------------------------------------------
>
> Now I included an ejb-jar.xml in my /classes/META-INF directory  
> within my local project and redefined the EntityManager as follows:
>
>
> -----------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
>                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd 
> "
>                version="3.0"
>                metadata-complete="true" >
>        <enterprise-beans>
>                <session>
>                        <ejb-name>CustomerManagerImpl</ejb-name>
>                        <business-local>company.CustomerManager</ 
> business-local>
>                        <ejb-class>company.CustomerManagerImpl</ejb- 
> class>
>                        <session-type>Stateless</session-type>
>                        <persistence-context-ref>
>                                <persistence-context-ref- 
> name>company.CustomerManagerImpl/entityManager</persistence-context- 
> ref-name>
>                                <persistence-unit-name>IisTestPU</ 
> persistence-unit-name>
>                        </persistence-context-ref>
>                </session>
>        </enterprise-beans>
> </ejb-jar>
> -----------------------------------------------------------------------------
>
> If I put anything wrong in this ejb-jar.xml I always receive an  
> error. So I assume, that the ejb-jar is interpreted correctly, but  
> anyways I receive an error when booting openEJB.
>
> ERROR - FAIL ... CustomerManagerImpl:   The persistence unit "" does  
> not exist.  Update the "entityManager" PersistenceContext ref to one  
> of the avail
> able units [CleoServicePU, IisTestPU] or declare the unit in a  
> persistence.xml like the following:<persistence xmlns="http://java.sun.com/xml/ns/persi
> stence" version="1.0"><persistence-unit name=""><jta-data- 
> source>java:openejb/Resource/myDataSource</jta-data-source><non-jta- 
> data-source>java:openejb
> /Resource/myUnmanagedDataSource</non-jta-data- 
> source><properties><property name="openjpa.jdbc.SynchronizeMappings"  
> value="buildSchema(ForeignKeys=true
> )"/></properties></persistence-unit></persistence>
>
>
> Did I miss anything?
>
> Thomas
>


Override PersistenceContext

Posted by Th...@partner.bmw.ch.
Hi @all,

I´d like to override the settings for the PersistenceContext, but somehow it does not work.
My Scenario is as follows: I´ve got a REFERENCED JAR and my local project. The referenced jar contains some stateless services, with an annotated EntityManager pointing to the default PersistenceContext without declaring a unitName.

Then I´ve got my project, which also has it´s own persistence.xml and some services. As there are 2 persistence-units-defintions now, the services from the referenced as well as those from my local project fail to start, because injection does not work anymore. So far so good! So I decided to override the persistenceUnit from the services in the referencedJar and point them to a specific persistence-unit-name.


This is my business class from the referenced jar (where CustomerManager is it´s local interface annotated with @Local):
-----------------------------------------------------------------------------
package company;

@Stateless
public class CustomerManagerImpl implements CustomerManager {

...
        @PersistenceContext
        private EntityManager entityManager;
...
}

-----------------------------------------------------------------------------

Now I included an ejb-jar.xml in my /classes/META-INF directory within my local project and redefined the EntityManager as follows:


-----------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
                version="3.0"
                metadata-complete="true" >
        <enterprise-beans>
                <session>
                        <ejb-name>CustomerManagerImpl</ejb-name>
                        <business-local>company.CustomerManager</business-local>
                        <ejb-class>company.CustomerManagerImpl</ejb-class>
                        <session-type>Stateless</session-type>
                        <persistence-context-ref>
                                <persistence-context-ref-name>company.CustomerManagerImpl/entityManager</persistence-context-ref-name>
                                <persistence-unit-name>IisTestPU</persistence-unit-name>
                        </persistence-context-ref>
                </session>
        </enterprise-beans>
</ejb-jar>
-----------------------------------------------------------------------------

If I put anything wrong in this ejb-jar.xml I always receive an error. So I assume, that the ejb-jar is interpreted correctly, but anyways I receive an error when booting openEJB.

ERROR - FAIL ... CustomerManagerImpl:   The persistence unit "" does not exist.  Update the "entityManager" PersistenceContext ref to one of the avail
able units [CleoServicePU, IisTestPU] or declare the unit in a persistence.xml like the following:<persistence xmlns="http://java.sun.com/xml/ns/persi
stence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb
/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true
)"/></properties></persistence-unit></persistence>


Did I miss anything?

Thomas

Re: R: R: How to enable/disable Hibernate EntityManager

Posted by David Blevins <da...@visi.com>.
Thanks, Paolo, for taking a shot at helping out Thomas.  You set a  
good example and it's very appreciated!

Thomas, we don't have any code that changes the provider on  
persistence-units.  Can you post your log output?  There should be  
some lines that look like:

Configuring PersistenceUnit(name={0}, provider={1})
PersistenceUnit(name={0}, provider={1})


-David


On Feb 6, 2009, at 7:00 AM, Paolo Spadafora wrote:

> I understand, probably david or some other openejb developer can  
> help you out.
>
> Paolo
>
>
> -----Messaggio originale-----
> Da: hamtho [mailto:thamacher@project-team.de]
> Inviato: venerdì 6 febbraio 2009 14.16
> A: users@openejb.apache.org
> Oggetto: Re: R: How to enable/disable Hibernate EntityManager
>
>
> Paolo,
>
> thanks for you reply.
> There is nothing really wrong with the  
> JBossTransactionManagerLookup. It´s
> just a kind of dynamic factory which chooses, which implementation  
> to use.
> But for this test-case I could also use the JBoss one.
>
> But my problem is not, that hibernate does not work correctly, but I  
> wonder
> why openEJB uses the plain org.hibernate.Hibernate implementation in  
> one
> case and in the other case it uses the Hibernate EntityManager
> (org.hibernate.ejb.HibernatePersistence), although in both cases I  
> defined
> to use the Hibernate EntityManager in the persistence.xml through the
> <provider>-tag.
>
> So there has to be a strategy how openEJB handles, which  
> implementation to
> use. I don´t know, if this comes through classpath-resolution or  
> anything
> else. But it behaves differently and I am trying to understand how  
> it works,
> to enable the Hibernate EntityManager specifically.
> I do not want the plain org.hibernate.Hibernate-session to be used.
>
> Do you understand what I mean?
>
> Thanks
> Thomas
>
>
>
>
>
> p.spadafora wrote:
>>
>> Hi,
>> I am not sure of your problem.
>> But I think
>> <property name="hibernate.hbm2ddl.auto" value="update" />
>>
>> Has the same meaning of
>> <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)" />
>>
>> Although, the second one is an openjpa property and should be  
>> ignored by
>> hibernate provider.
>>
>> Any particular reason not to use the
>> org.hibernate.transaction.JBossTransactionManagerLookup class?
>>
>> Bye,
>>
>> Paolo
>>
>>
>> -----Messaggio originale-----
>> Da: hamtho [mailto:thamacher@project-team.de]
>> Inviato: venerdì 6 febbraio 2009 11.14
>> A: users@openejb.apache.org
>> Oggetto: How to enable/disable Hibernate EntityManager
>>
>>
>> Hi,
>>
>> I´m still struggling with the EXTENDED Persistence context and
>> EntityManager.
>> Maybe it has anything to do, because i use the Hibernate  
>> EntityManager.
>> But I´ve got the strange behaviour, that in one test case - which  
>> works
>> (!!!) - only the Hibernate-Session is loaded while openEJB starts  
>> up and
>> in
>> the other test case - which does not work - the  
>> HibernateEntityManager is
>> used.
>> The persistence.xml is identical in both cases.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence"  
>> version="1.0">
>> 	<persistence-unit name="IisPU">
>> 		<jta-data-source>gerdaDatabase</jta-data-source>
>> 		 <non-jta-data-source>gerdaDatabaseUnmanaged</non-jta-data-source>
>> 		 <provider>org.hibernate.ejb.HibernatePersistence</provider>
>> 		
>> 		<properties>
>> 			<property name="hibernate.hbm2ddl.auto" value="update" />
>> 			<property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)" />
>> 		 <property name="hibernate.transaction.manager_lookup_class"
>> value="ch.bmw.service.DynamicTransactionManagerLookup"/>
>> 		
>> 		</properties>
>> 	</persistence-unit>
>> </persistence>
>>
>> Is there any chance to control wheater openEJB should use Hibernate  
>> or
>> HibernateEntityManager or what is the strategy of openEJB to decide  
>> which
>> implementation to load?
>>
>> Maybe someone can help
>>
>> Thomas
>> -- 
>> View this message in context:
>> http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21869752.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21872186.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
>


R: R: How to enable/disable Hibernate EntityManager

Posted by Paolo Spadafora <p....@gmail.com>.
I understand, probably david or some other openejb developer can help you out.

Paolo 


-----Messaggio originale-----
Da: hamtho [mailto:thamacher@project-team.de] 
Inviato: venerdì 6 febbraio 2009 14.16
A: users@openejb.apache.org
Oggetto: Re: R: How to enable/disable Hibernate EntityManager


Paolo,

thanks for you reply.
There is nothing really wrong with the JBossTransactionManagerLookup. It´s
just a kind of dynamic factory which chooses, which implementation to use.
But for this test-case I could also use the JBoss one.

But my problem is not, that hibernate does not work correctly, but I wonder
why openEJB uses the plain org.hibernate.Hibernate implementation in one
case and in the other case it uses the Hibernate EntityManager
(org.hibernate.ejb.HibernatePersistence), although in both cases I defined
to use the Hibernate EntityManager in the persistence.xml through the
<provider>-tag.

So there has to be a strategy how openEJB handles, which implementation to
use. I don´t know, if this comes through classpath-resolution or anything
else. But it behaves differently and I am trying to understand how it works,
to enable the Hibernate EntityManager specifically.
I do not want the plain org.hibernate.Hibernate-session to be used.

Do you understand what I mean?

Thanks
Thomas





p.spadafora wrote:
> 
> Hi,
> I am not sure of your problem.
> But I think 
> <property name="hibernate.hbm2ddl.auto" value="update" />
> 
> Has the same meaning of
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />
> 
> Although, the second one is an openjpa property and should be ignored by
> hibernate provider.
> 
> Any particular reason not to use the
> org.hibernate.transaction.JBossTransactionManagerLookup class? 
> 
> Bye,
> 
> Paolo
> 
> 
> -----Messaggio originale-----
> Da: hamtho [mailto:thamacher@project-team.de] 
> Inviato: venerdì 6 febbraio 2009 11.14
> A: users@openejb.apache.org
> Oggetto: How to enable/disable Hibernate EntityManager
> 
> 
> Hi,
> 
> I´m still struggling with the EXTENDED Persistence context and
> EntityManager.
> Maybe it has anything to do, because i use the Hibernate EntityManager.
> But I´ve got the strange behaviour, that in one test case - which works
> (!!!) - only the Hibernate-Session is loaded while openEJB starts up and
> in
> the other test case - which does not work - the HibernateEntityManager is
> used.
> The persistence.xml is identical in both cases.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
> 	<persistence-unit name="IisPU">
> 		<jta-data-source>gerdaDatabase</jta-data-source>
> 		 <non-jta-data-source>gerdaDatabaseUnmanaged</non-jta-data-source> 
> 		 <provider>org.hibernate.ejb.HibernatePersistence</provider>
> 		 
> 		<properties>
> 			<property name="hibernate.hbm2ddl.auto" value="update" />
> 			<property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />
> 		 <property name="hibernate.transaction.manager_lookup_class"
> value="ch.bmw.service.DynamicTransactionManagerLookup"/>
> 		
> 		</properties>
> 	</persistence-unit>
> </persistence>
> 
> Is there any chance to control wheater openEJB should use Hibernate or
> HibernateEntityManager or what is the strategy of openEJB to decide which
> implementation to load?
> 
> Maybe someone can help
> 
> Thomas
> -- 
> View this message in context:
> http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21869752.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21872186.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Re: R: How to enable/disable Hibernate EntityManager

Posted by hamtho <th...@project-team.de>.
Paolo,

thanks for you reply.
There is nothing really wrong with the JBossTransactionManagerLookup. It´s
just a kind of dynamic factory which chooses, which implementation to use.
But for this test-case I could also use the JBoss one.

But my problem is not, that hibernate does not work correctly, but I wonder
why openEJB uses the plain org.hibernate.Hibernate implementation in one
case and in the other case it uses the Hibernate EntityManager
(org.hibernate.ejb.HibernatePersistence), although in both cases I defined
to use the Hibernate EntityManager in the persistence.xml through the
<provider>-tag.

So there has to be a strategy how openEJB handles, which implementation to
use. I don´t know, if this comes through classpath-resolution or anything
else. But it behaves differently and I am trying to understand how it works,
to enable the Hibernate EntityManager specifically.
I do not want the plain org.hibernate.Hibernate-session to be used.

Do you understand what I mean?

Thanks
Thomas





p.spadafora wrote:
> 
> Hi,
> I am not sure of your problem.
> But I think 
> <property name="hibernate.hbm2ddl.auto" value="update" />
> 
> Has the same meaning of
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />
> 
> Although, the second one is an openjpa property and should be ignored by
> hibernate provider.
> 
> Any particular reason not to use the
> org.hibernate.transaction.JBossTransactionManagerLookup class? 
> 
> Bye,
> 
> Paolo
> 
> 
> -----Messaggio originale-----
> Da: hamtho [mailto:thamacher@project-team.de] 
> Inviato: venerdì 6 febbraio 2009 11.14
> A: users@openejb.apache.org
> Oggetto: How to enable/disable Hibernate EntityManager
> 
> 
> Hi,
> 
> I´m still struggling with the EXTENDED Persistence context and
> EntityManager.
> Maybe it has anything to do, because i use the Hibernate EntityManager.
> But I´ve got the strange behaviour, that in one test case - which works
> (!!!) - only the Hibernate-Session is loaded while openEJB starts up and
> in
> the other test case - which does not work - the HibernateEntityManager is
> used.
> The persistence.xml is identical in both cases.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
> 	<persistence-unit name="IisPU">
> 		<jta-data-source>gerdaDatabase</jta-data-source>
> 		 <non-jta-data-source>gerdaDatabaseUnmanaged</non-jta-data-source> 
> 		 <provider>org.hibernate.ejb.HibernatePersistence</provider>
> 		 
> 		<properties>
> 			<property name="hibernate.hbm2ddl.auto" value="update" />
> 			<property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />
> 		 <property name="hibernate.transaction.manager_lookup_class"
> value="ch.bmw.service.DynamicTransactionManagerLookup"/>
> 		
> 		</properties>
> 	</persistence-unit>
> </persistence>
> 
> Is there any chance to control wheater openEJB should use Hibernate or
> HibernateEntityManager or what is the strategy of openEJB to decide which
> implementation to load?
> 
> Maybe someone can help
> 
> Thomas
> -- 
> View this message in context:
> http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21869752.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21872186.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


R: How to enable/disable Hibernate EntityManager

Posted by Paolo Spadafora <p....@gmail.com>.
Hi,
I am not sure of your problem.
But I think 
<property name="hibernate.hbm2ddl.auto" value="update" />

Has the same meaning of
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />

Although, the second one is an openjpa property and should be ignored by hibernate provider.

Any particular reason not to use the org.hibernate.transaction.JBossTransactionManagerLookup class? 

Bye,

Paolo


-----Messaggio originale-----
Da: hamtho [mailto:thamacher@project-team.de] 
Inviato: venerdì 6 febbraio 2009 11.14
A: users@openejb.apache.org
Oggetto: How to enable/disable Hibernate EntityManager


Hi,

I´m still struggling with the EXTENDED Persistence context and
EntityManager.
Maybe it has anything to do, because i use the Hibernate EntityManager.
But I´ve got the strange behaviour, that in one test case - which works
(!!!) - only the Hibernate-Session is loaded while openEJB starts up and in
the other test case - which does not work - the HibernateEntityManager is
used.
The persistence.xml is identical in both cases.

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
	<persistence-unit name="IisPU">
		<jta-data-source>gerdaDatabase</jta-data-source>
		 <non-jta-data-source>gerdaDatabaseUnmanaged</non-jta-data-source> 
		 <provider>org.hibernate.ejb.HibernatePersistence</provider>
		 
		<properties>
			<property name="hibernate.hbm2ddl.auto" value="update" />
			<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
		 <property name="hibernate.transaction.manager_lookup_class"
value="ch.bmw.service.DynamicTransactionManagerLookup"/>
		
		</properties>
	</persistence-unit>
</persistence>

Is there any chance to control wheater openEJB should use Hibernate or
HibernateEntityManager or what is the strategy of openEJB to decide which
implementation to load?

Maybe someone can help

Thomas
-- 
View this message in context: http://www.nabble.com/How-to-enable-disable-Hibernate-EntityManager-tp21869752p21869752.html
Sent from the OpenEJB User mailing list archive at Nabble.com.