openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hans J. Prueller" <hans.pruel...@gmx.net>
Subject AW: Using OpenJPA within an "old" J2EE1.4 container with managed transactions?
Date Tue, 06 Feb 2007 15:55:41 GMT
Thank you - I should have guessed that accessing UserTransaction in this
configuration is not allowed. What I tried was to "simply" run the
"hellojpa" example within our .ear application.

I removed the access to UserTransaction in my test method and it seems
to work now. Now I get an error message regarding the enhancer, but that’s
because I did not invoke the enhancer on the testclass yet. So I guess using
JOnAS' managed transactions should work now.

Thank you!

Hans

> -----Ursprüngliche Nachricht-----
> Von: Patrick Linskey [mailto:plinskey@bea.com]
> Gesendet: Montag, 05. Februar 2007 22:09
> An: open-jpa-dev@incubator.apache.org
> Betreff: RE: Using OpenJPA within an "old" J2EE1.4 container with managed
> transactions?
> 
> Looking at the trace, it looks like OpenJPA is being deployed correctly
> when you used java:comp/UserTransaction:
> 
> > 156  INFO   [RMI TCP Connection(7)-192.168.0.6] openjpa.Runtime -
> > Starting OpenJPA 0.9.6-incubating
> 
> This means that OpenJPA loaded the configuration and initialized.
> 
> > 359  INFO   [RMI TCP Connection(7)-192.168.0.6] openjpa.jdbc.JDBC -
> > OpenJPA will now connect to the database to attempt to determine
> > what type of database dictionary to use.  To prevent this connection
> > in the future, set your openjpa.jdbc.DBDictionary configuration
> > property to the appropriate value for your database (see the
> > documentation for available values).
> > 469  INFO   [RMI TCP Connection(7)-192.168.0.6] openjpa.jdbc.JDBC -
> > Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary"
> > (MySQL 5.0.27-community-nt ,MySQL-AB JDBC Driver mysql-connector-
> > java-5.0.4 ( $Date: 2006-10-19 17:47:48 +0200 (Thu, 19 Oct 2006) $,
> > $Revision: 5908 $ )).
> 
> This means that we were able to connect to the database and figure out
> that you're using MySQL.
> 
> > org.apache.openjpa.persistence.InvalidStateException:
> > You cannot access the EntityTransaction when using managed transactions.
> >        at
> org.apache.openjpa.persistence.EntityManagerImpl.getTransaction(EntityMana
> gerImpl.java:360)
> >        at
> >com.lbslogics.ims.system.ejb.IMSSystemBean.initializeJPA(IMSSystemBean.ja
> va:1102)
> >        at
> com.lbslogics.ims.system.ejb.IMSSystemBean.startup(IMSSystemBean.java:1061
> )
> >        at
> >
> org.objectweb.jonas_gen.com.lbslogics.ims.system.interfaces.JOnASIMSSystem
> Bean2005147373Remote.startup(JOnASIMSSystemBean2005147373Remote.java:23
> 4)
> 
> It looks like IMSSystemBean.initializeJPA() is trying to invoked
> EntityManager.getTransaction(). Since you're using JTA, you're not allowed
> to use getTransaction(); all transaction management must happen through
> container-managed transactions or bean-managed transaction code.
> 
> -Patrick
> 
> --
> Patrick Linskey
> BEA Systems, Inc.
> 
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
> 
> > -----Original Message-----
> > From: Hans J. Prueller [mailto:hans.prueller@gmx.net]
> > Sent: Monday, February 05, 2007 12:54 PM
> > To: open-jpa-dev@incubator.apache.org
> > Subject: AW: Using OpenJPA within an "old" J2EE1.4 container
> > with managed transactions?
> >
> > >> If that doesn't work, can you post the complete stack trace?
> >
> > Thank you for your help. Unfortunately it did NOT work. I'm
> > not sure what
> > the exact problem is, here are the strack-traces:
> >
> > first case:
> > ====================================================================
> > openjpa.ManagedRuntime:
> > jndi(TransactionManagerName=java:comp/UserTransaction)
> >
> > 2007-02-05 21:33:32,109 : IMSSystemBean.initializeJPA :
> > initializing JPA
> > persist
> > ence.
> > 2007-02-05 21:33:33,796 : IMSSystemBean.initializeJPA : testing JPA
> > persistence
> > 156  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.Runtime - Starting
> > OpenJ
> > PA 0.9.6-incubating
> > 359  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.jdbc.JDBC - OpenJPA
> > will
> >  now connect to the database to attempt to determine what
> > type of database
> > dicti
> > onary to use.  To prevent this connection in the future, set your
> > openjpa.jdbc.D
> > BDictionary configuration property to the appropriate value for your
> > database (s
> > ee the documentation for available values).
> > 469  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.jdbc.JDBC - Using
> > dictio
> > nary class "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL
> > 5.0.27-community
> > -nt ,MySQL-AB JDBC Driver mysql-connector-java-5.0.4 ( $Date:
> > 2006-10-19
> > 17:47:4
> > 8 +0200 (Thu, 19 Oct 2006) $, $Revision: 5908 $ )).
> > 812  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.MetaData - Found 1
> > class
> > es with metadata in 15 milliseconds.
> > 844  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.MetaData - Found 1
> > class
> > es with metadata in 0 milliseconds.
> > 1094  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.MetaData - Parsing
> > clas
> > s "com.lbslogics.ims.util.JPATestObject".
> > 1094  INFO   [RMI TCP Connection(7)-192.168.0.6]
> > openjpa.MetaData - Parsing
> > pack
> > age "com.lbslogics.ims.util.JPATestObject".
> > 1359  INFO   [RMI TCP Connection(7)-192.168.0.6] openjpa.jdbc.Schema -
> > Reading t
> > able information for schema name "null", table name "JPATestObject".
> > 1437  INFO   [RMI TCP Connection(7)-192.168.0.6] openjpa.jdbc.Schema -
> > Reading s
> > equence information for schema "null", sequence name "null".
> > <4|false|0.9.6-incubating>
> > org.apache.openjpa.persistence.InvalidStateException:
> >  You cannot access the EntityTransaction when using managed
> > transactions.
> >         at
> > org.apache.openjpa.persistence.EntityManagerImpl.getTransaction(Entit
> > yManagerImpl.java:360)
> >         at
> > com.lbslogics.ims.system.ejb.IMSSystemBean.initializeJPA(IMSSystemBea
> > n.java:1102)
> >         at
> > com.lbslogics.ims.system.ejb.IMSSystemBean.startup(IMSSystemBean.java
> > :1061)
> >         at
> > org.objectweb.jonas_gen.com.lbslogics.ims.system.interfaces.JOnASIMSS
> > ystemBean2005147373Remote.startup(JOnASIMSSystemBean2005147373
> > Remote.java:23
> > 4)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> > java:39)
> >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> > sorImpl.java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:585)
> >         at
> > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
> >         at
> > org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.dispatch(JUnica
> > stServerRef.java:143)
> >         at sun.rmi.transport.Transport$1.run(Transport.java:153)
> >         at java.security.AccessController.doPrivileged(Native Method)
> >         at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
> >         at
> > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
> > 66)
> >         at
> > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
> > .java:707)
> >         at java.lang.Thread.run(Thread.java:595)
> > 2007-02-05 21:33:35,187 : IMSSystemBean.startup : ERROR while
> > initializing
> > JPA:
> > You cannot access the EntityTransaction when using managed
> > transactions.
> >
> >
> > second case:
> > ====================================================================
> > openjpa.ManagedRuntime: jndi(TransactionManagerName=/UserTransaction)
> >
> > <0|false|0.9.6-incubating>
> > org.apache.openjpa.persistence.PersistenceException:
> > /UserTransaction
> >         at
> > org.apache.openjpa.kernel.AbstractBrokerFactory.syncWithManagedTransa
> > ction(AbstractBrokerFactory.java:633)
> >         at
> > org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:292)
> >         at
> > org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBro
> > kerFactory.java:165)
> >         at
> > org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(Delegatin
> > gBrokerFactory.java:139)
> >         at
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityM
> > anager(EntityManagerFactoryImpl.java:187)
> >         at
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityM
> > anager(EntityManagerFactoryImpl.java:140)
> >         at
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityM
> > anager(EntityManagerFactoryImpl.java:52)
> >         at
> > com.lbslogics.ims.system.ejb.IMSSystemBean.initializeJPA(IMSSystemBea
> > n.java:1099)
> >         at
> > com.lbslogics.ims.system.ejb.IMSSystemBean.startup(IMSSystemBean.java
> > :1061)
> >         at
> > org.objectweb.jonas_gen.com.lbslogics.ims.system.interfaces.JOnASIMSS
> > ystemBean2005147373Remote.startup(JOnASIMSSystemBean2005147373
> > Remote.java:23
> > 4)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> > java:39)
> >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> > sorImpl.java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:585)
> >         at
> > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
> >         at
> > org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.dispatch(JUnica
> > stServerRef.java:143)
> >         at sun.rmi.transport.Transport$1.run(Transport.java:153)
> >         at java.security.AccessController.doPrivileged(Native Method)
> >         at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
> >         at
> > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
> > 66)
> >         at
> > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
> > .java:707)
> >         at java.lang.Thread.run(Thread.java:595)
> > Caused by: javax.naming.NameNotFoundException: /UserTransaction
> >         at
> > com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java
> > :95)
> >         at javax.naming.InitialContext.lookup(InitialContext.java:355)
> >         at
> > org.objectweb.carol.jndi.spi.AbsContext.lookup(AbsContext.java:140)
> >         at
> > org.objectweb.carol.jndi.spi.AbsContext.lookup(AbsContext.java:150)
> >         at javax.naming.InitialContext.lookup(InitialContext.java:351)
> >         at
> > org.objectweb.carol.jndi.spi.MultiContext.lookup(MultiContext.java:11
> > 8)
> >         at javax.naming.InitialContext.lookup(InitialContext.java:351)
> >         at
> > org.apache.openjpa.ee.JNDIManagedRuntime.getTransactionManager(JNDIMa
> > nagedRuntime.java:51)
> >         at
> > org.apache.openjpa.kernel.AbstractBrokerFactory.syncWithManagedTransa
> > ction(AbstractBrokerFactory.java:598)
> >         ... 21 more
> > 2007-02-05 21:44:10,921 : IMSSystemBean.startup : ERROR while
> > initializing
> > JPA:
> > /UserTransaction
> >
> > *************************************************
> >
> >
> > From my understanding it seems that there is a fatal error in
> > the second
> > case, like openJPA was not able to even lookup JOnAS'
> > transaction manager.
> > It seems to me that in the first case, the transaction
> > manager lookup worked
> > but there is another subsequent error?
> >
> > <4|false|0.9.6-incubating>
> > org.apache.openjpa.persistence.InvalidStateException:
> >  You cannot access the EntityTransaction when using managed
> > transactions.
> >         at
> > org.apache.openjpa.persistence.EntityManagerImpl.getTransaction(Entit
> > yManagerImpl.java:360)
> >
> > Can you explain what this message means exactly?
> >
> > thank you in advance,
> > HANS
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Marc Prud'hommeaux [mailto:mprudhomapache@gmail.com]
> > Im Auftrag von
> > > Marc Prud'hommeaux
> > > Gesendet: Montag, 05. Februar 2007 21:19
> > > An: open-jpa-dev@incubator.apache.org
> > > Betreff: Re: Using OpenJPA within an "old" J2EE1.4
> > container with managed
> > > transactions?
> > >
> > > Hans-
> > >
> > > We might not have Jonas' TransactionManager location configured in
> > > the automatic TM lookup in OpenJPA. Can you try to manually specify
> > > it with the following property:
> > >
> > >     openjpa.ManagedRuntime: jndi(TransactionManagerName=java:comp/
> > > UserTransaction)
> > >
> > > if that doesn't work, try:
> > >
> > >     openjpa.ManagedRuntime: jndi(TransactionManagerName=/
> > > UserTransaction)
> > >
> > > (apparently, Jonas' UserTransaction implementation is also their
> > > TransactionManager implementation)
> > >
> > > If that doesn't work, can you post the complete stack trace?
> > >
> > > If it does work, please let us know so we can add it to the list of
> > > auto-discovered transaction managers.
> > >
> > >
> > >
> > > On Feb 5, 2007, at 12:05 PM, Hans J. Prueller wrote:
> > >
> > > > Hi there,
> > > >
> > > >
> > > >
> > > > I'm trying to migrate our "old" J2EE1.4 / EJB2.1 applications
> > > > persistence to
> > > > openJPA. Currently I got stuck when
> > > >
> > > > trying to configure OpenJPA persistence, when creating the
> > > > EntityManagerFactory and the EntityManager instance,
> > > >
> > > > I get the following error:
> > > >
> > > >
> > > >
> > > > <4|true|0.9.6-incubating>
> > > > org.apache.openjpa.persistence.InvalidStateException:
> > > >
> > > > Could not perform automatic lookup of EJB container's
> > > > javax.transaction.Transact
> > > >
> > > > ionManager implementation. Please ensure that you are running the
> > > > application fr
> > > >
> > > > om within an EJB 1.1 compliant EJB container, and then set the
> > > > org.apache.openjp
> > > >
> > > > a.ManagedRuntime property to the appropriate value to obtain the
> > > > TransactionMana
> > > >
> > > > ger.
> > > >
> > > >         at
> > > >
> > org.apache.openjpa.ee.AutomaticManagedRuntime.getTransactionManager(A
> > > >
> > > > utomaticManagedRuntime.java:180)
> > > >
> > > >         at
> > > >
> > org.apache.openjpa.kernel.AbstractBrokerFactory.syncWithManagedTransa
> > > >
> > > > ction(AbstractBrokerFactory.java:598)
> > > >
> > > >         at
> > > >
> > org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:292)
> > > >
> > > >         at
> > > >
> > org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBro
> > > >
> > > > kerFactory.java:165)
> > > >
> > > >         at
> > > >
> > org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(Delegatin
> > > >
> > > > gBrokerFactory.java:139)
> > > >
> > > >         at
> > > >
> > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityM
> > > >
> > > > anager(EntityManagerFactoryImpl.java:187)
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Currently I'm running the application within the JOnAS 4.8.3 J2EE
> > > > Server.
> > > > How can I configure open JPA to
> > > >
> > > > use the provided managed Transactions of JOnAS? (this
> > works also with
> > > > Hibernate 2.x so I assume it should
> > > >
> > > > somehow be possible with openJPA?)
> > > >
> > > >
> > > >
> > > > any help appreciated!
> > > >
> > > >
> > > >
> > > > regards,
> > > >
> > > > HANS
> > > >
> > > >
> > > >
> > > > ===========================
> > > > virtually hanzz...
> > > >
> > > >
> > > >
> > > >  <http://hanzz.zapto.org> http://hanzz.zapto.org (personal)
> > > >  <http://www.cse.dmu.ac.uk/~hansp> http://www.cse.dmu.ac.uk/~hansp
> > > > (research)
> > > >
> > > >
> > > >
> >
> >


Mime
View raw message