Announcement Announcement Module
Collapse
No announcement yet.
JPA error: A JTA EntityManager cannot use getTransaction() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA error: A JTA EntityManager cannot use getTransaction()

    Does any one know whats wrong here.

    Exception
    HTML Code:
    javax.ejb.EJBException: EJB Exception: ; nested exception is: 
    	org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
    	at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
    	at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
    	at $Proxy0.save(Unknown Source)
    	at egm.poc.jpa.JPATestClient.main(JPATestClient.java:36)
    Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
    	at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy80.save(Unknown Source)
    	at egm.poc.jpa.JPATestBean.save(JPATestBean.java:50)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
    	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
    	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
    	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
    	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
    	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    	at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
    	at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
    	at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
    	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    	at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
    	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
    	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    	at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
    	at $Proxy76.save(Unknown Source)
    	at egm.poc.jpa.JPATestBean_apxnvk_JPATestBeanRemoteImpl.save(JPATestBean_apxnvk_JPATestBeanRemoteImpl.java:217)
    	at egm.poc.jpa.JPATestBean_apxnvk_JPATestBeanRemoteImpl_WLSkel.invoke(Unknown Source)
    	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
    	at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
    	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
    	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    	at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
    	at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
    	at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)
    	at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)
    	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:52)
    	at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:330)
    	... 39 more
    spring file
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:context="http://www.springframework.org/schema/context"
    		xmlns:jee="http://www.springframework.org/schema/jee"
    		xmlns:tx="http://www.springframework.org/schema/tx"
    		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    				http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    				http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
    
       
       <bean id="jpaTemplate"
    		class="org.springframework.orm.jpa.JpaTemplate">
    		<property name="entityManagerFactory"
    			ref="entityManagerFactory" />
    	</bean>
       
    
      <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
          <property name="dataSource" ref="dataSource"/>
          <property name="persistenceUnitName" value="egm"/>
          <property name="jpaVendorAdapter">
    	    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">      
    	     <property name="showSql" value="true" />      
    	     <property name="generateDdl" value="false" />       
    	     <property name="database" value="ORACLE"/>
        	 </bean>
          </property>
    		<property name="jpaProperties">
    			<props>
    				<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
    				<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</prop>
    			</props>
    		</property>
      </bean> 
       
       <jee:jndi-lookup id="dataSource" jndi-name="jdbc/EGMDS"/>
       
       <tx:annotation-driven transaction-manager="transactionManager"/>
    
       <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
          <property name="entityManagerFactory" ref="entityManagerFactory"/>
          <property name="dataSource" ref="dataSource"/>
       </bean>
       
       <bean id="auditDAO" class="egm.poc.jpa.AuditInfoDAO">
    		<property name="jpaTemplate" ref="jpaTemplate" />
    	</bean>
    
    </beans>
    persistance.xml
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
    
    	<persistence-unit name="egm" transaction-type="JTA">
    	<jta-data-source>jdbc/EGMDS</jta-data-source>	
    	<properties>
    			<property name="hibernate.show_sql" value="true" />
    			<property name="hibernate.transaction.factory_class"
    				value="org.hibernate.transaction.JTATransactionFactory" />
    			<property name="hibernate.transaction.manager_lookup_class"
    				value="org.hibernate.transaction.WeblogicTransactionManagerLookup" />
    			<property name="jta.UserTransaction"
    				value="java:comp/UserTransaction" />
    	</properties>		
    	</persistence-unit>
    
    
    </persistence>
    Even I have tried without <properties> tags in persistance.xml

    Please help.

    Saji
Working...
X