java - "No transaction is in progress" after migrating to Wildfly -


we have spring 3.6 application hibernate 4.2.2 working fine on glassfish 4, until migrated wildfly 8.2. use spring-data 1.5.0.

the following 2 problems appear:

  1. when saving entity, it's not persisted. no exception thrown here, save method in org.springframework.data.jpa.repository.support.simplejparepository returns entity no id assigned

  2. when updating (merging) entity, flush throws exception: javax.persistence.transactionrequiredexception: no transaction in progress

persistence.xml:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd">  <persistence-unit name="persistencesql"     transaction-type="jta">     <provider>org.hibernate.ejb.hibernatepersistence</provider>     <jta-data-source>jdbc/mysqlpool</jta-data-source>      <!-- domain classes -->     <class>org.common.model.domain.company</class>     ...     <class>org.common.model.system.rammetric</class>      <properties>          <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.jbossstandalonejtaplatform" />          <property name="hibernate.dialect" value="org.hibernate.dialect.mysqldialect" />         <property name="hibernate.hbm2ddl.auto" value="update" />         <property name="hibernate.show_sql" value="true" />      </properties> </persistence-unit> 

root context:

<?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:jpa="http://www.springframework.org/schema/data/jpa" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd                     http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd                     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">  <!-- root context: defines shared resources visible other web components -->  <!-- _________________________________________datasource______________________________________________________ -->    <bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean">      <property name="jndiname" value="jdbc/mysqlpool" />     <property name="lookuponstartup" value="false" />     <property name="cache" value="true" />     <property name="proxyinterface" value="javax.sql.datasource" />  </bean>  <!-- _________________________________________entitymanagerfactory______________________________________________________ -->   <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean">      <property name="persistenceunitname" value="persistencesql" />      <property name="jpavendoradapter">         <bean class="org.springframework.orm.jpa.vendor.hibernatejpavendoradapter" />     </property> </bean>  <!-- _________________________________________transaction manager________________________________________________________ -->   <bean id="transactionmanager" class="org.springframework.transaction.jta.jtatransactionmanager">     <property name="allowcustomisolationlevels" value="true" /> </bean>  <jpa:repositories base-package="com.ototrak.datacenter.repository.* , com.ototrak.datacenter.domain" entity-manager-factory-ref="entitymanagerfactory" transaction-manager-ref="transactionmanager" /> 

as mentioned, app worked fine on glassfish. point had exclude modules wildfly, org.jboss.resteasy.resteasy-jackson2-provider json serialization working. don't use provided dependencies, it's possible have conflicts provided wildfly modules. have extensive junit coverage , tests pass, it's has modules provided wildfly.

we had change following in persistence.xml:

 <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.sunonejtaplatform" /> 

to:

 <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.jbossstandalonejtaplatform" /> 

to select queries work (which work fine now).

stack trace:

org.springframework.dao.invaliddataaccessapiusageexception: no transaction in progress; nested exception javax.persistence.transactionrequiredexception: no transaction in progress     @ org.springframework.orm.jpa.entitymanagerfactoryutils.convertjpaaccessexceptionifpossible(entitymanagerfactoryutils.java:316)     @ org.springframework.orm.jpa.vendor.hibernatejpadialect.translateexceptionifpossible(hibernatejpadialect.java:108)     @ org.springframework.orm.jpa.abstractentitymanagerfactorybean.translateexceptionifpossible(abstractentitymanagerfactorybean.java:403)     @ org.springframework.dao.support.chainedpersistenceexceptiontranslator.translateexceptionifpossible(chainedpersistenceexceptiontranslator.java:58)     @ org.springframework.dao.support.dataaccessutils.translateifnecessary(dataaccessutils.java:213)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:163)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.data.jpa.repository.support.lockmoderepositorypostprocessor$lockmodepopulatingmethodintercceptor.invoke(lockmoderepositorypostprocessor.java:92)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:91)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204)     @ com.sun.proxy.$proxy82.saveandflush(unknown source)     @ com.ototrak.datacenter.service.persistance.sql.impl.firmwaretableserviceimpl.update(firmwaretableserviceimpl.java:56)     @ com.ototrak.datacenter.api.processing.task.firmwareprocessingtask.updateentity(firmwareprocessingtask.java:180)     @ com.ototrak.datacenter.api.processing.task.abs.abstractprocessingtask.run(abstractprocessingtask.java:143)     @ java.util.concurrent.executors$runnableadapter.call(executors.java:471)     @ java.util.concurrent.futuretask.run(futuretask.java:262)     @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.access$201(scheduledthreadpoolexecutor.java:178)     @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor.java:292)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:745) caused by: javax.persistence.transactionrequiredexception: no transaction in progress     @ org.hibernate.jpa.spi.abstractentitymanagerimpl.checktransactionneeded(abstractentitymanagerimpl.java:1171)     @ org.hibernate.jpa.spi.abstractentitymanagerimpl.flush(abstractentitymanagerimpl.java:1332)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.springframework.orm.jpa.extendedentitymanagercreator$extendedentitymanagerinvocationhandler.invoke(extendedentitymanagercreator.java:366)     @ com.sun.proxy.$proxy65.flush(unknown source)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.springframework.orm.jpa.sharedentitymanagercreator$sharedentitymanagerinvocationhandler.invoke(sharedentitymanagercreator.java:241)     @ com.sun.proxy.$proxy65.flush(unknown source)     @ org.springframework.data.jpa.repository.support.simplejparepository.flush(simplejparepository.java:416)     @ org.springframework.data.jpa.repository.support.simplejparepository.saveandflush(simplejparepository.java:384)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.executemethodon(repositoryfactorysupport.java:358)     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:343)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:96)     @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:260)     @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:155)     ... 17 more 


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -