Hi,
There are two transaction models you can use in a Java EE container.
If you use the JTA datasource, you need to use the Java EE transaction
manager. If you use only a non-JTA datasource, you can manage the
transactions using EntityTransaction.
I don't know the details with regard to integrating with Spring, but
you might be ok with just using the non-JTA datasource in your
environment. If you use the JTA datasource, you need to use the
managed transaction interface (I recall you can look this up as a JNDI
resource).
Craig
On Dec 16, 2009, at 8:45 AM, KARR, DAVID (ATTCINW) wrote:
I have an app using Spring 2.5.6, OpenJPA 1.2.1, and WebLogic
10.3.2. I
specified a JTA datasource in the persistence.xml. I have a Spring
controller that calls my DAO class which uses the EntityManager. This
is working ok with respect to transactions. As my app is only going
to
be reading the database, I would think I wouldn't need transactions.
However, because of one problem I'm having with traversing an
association path, I thought I would try to implement a transactional
service layer, and do the association walking within that layer.
So, I added a class with a "@Transactional" method and put that in
between the Controller and the DAO. Now, I'm seeing the following
exception stack trace:
--------------------
Caused by:
org.springframework.transaction.CannotCreateTransactionException:
Could
not open JPA EntityManager for transaction; nested exception is
<openjpa-1.2.1-r752877:753278 nonfatal user error>
org.apache.openjpa.persistence.InvalidStateException: You cannot
access
the EntityTransaction when using managed transactions.
at
org
.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransaction
Manager.java:375)
at
org
.springframework.transaction.support.AbstractPlatformTransactionManag
er.getTransaction(AbstractPlatformTransactionManager.java:374)
at
org
.springframework.transaction.interceptor.TransactionAspectSupport.cre
ateTransactionIfNecessary(TransactionAspectSupport.java:263)
at
org
.springframework.transaction.interceptor.TransactionInterceptor.invok
e(TransactionInterceptor.java:101)
at
org
.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Ref
lectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.Cglib2AopProxy
$DynamicAdvisedIntercept
or.intercept(Cglib2AopProxy.java:635)
at
com.att.ecom.dynamiccontent.service.CatalogService$$EnhancerByCGLIB$
$5a7
c3444.retrieveCatalogTree(<generated>)
at
com.att.ecom.dynamiccontent.content.Content.getCatalog(Content.java:
35)
--------------------
Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:[email protected]
P.S. A good JDO? O, Gasp!