Hi,
I had been setting up JTA transaction in my app.
I have search through the forums and the internet.
But still, i not able to get it work.
I have done the following.
1. set up my data source in jboss 7. I am using MYSQL
2. set up jndi lookup in applicationContext.xml
3. created org.springframework.transaction.jta.JtaTransaction Manager beans
4. using AOP tx.:advice to pointcut my 'service' layer
Below is the log output for the jboss datasource and the JTAtransactionManager
Below is the error stack trace.
My applicationContext.xml
this is my hibernateProperties
I hope i am giving enough informations.
I have been trying days to make it work.
Thank you in advance.
I had been setting up JTA transaction in my app.
I have search through the forums and the internet.
But still, i not able to get it work.
I have done the following.
1. set up my data source in jboss 7. I am using MYSQL
2. set up jndi lookup in applicationContext.xml
3. created org.springframework.transaction.jta.JtaTransaction Manager beans
4. using AOP tx.:advice to pointcut my 'service' layer
Below is the log output for the jboss datasource and the JTAtransactionManager
Code:
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:/ecatalogAdminDS]
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:/ecatalogDS]
[org.springframework.transaction.jta.JtaTransactionManager] (MSC service thread 1-2) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@9f515e
[org.springframework.transaction.jta.JtaTransactionManager] (MSC service thread 1-2) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@c2336
[org.springframework.transaction.jta.JtaTransactionManager] (MSC service thread 1-2) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@dbda5c
Below is the error stack trace.
Code:
org.hibernate.HibernateException: No Session found for current thread
org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:941)
com.b2b.spring.dao.HibernateBaseDAO.getCurrentSession(HibernateBaseDAO.java:25)
com.b2b.admin.dao.OrganizationDAOImpl.listById(OrganizationDAOImpl.java:33)
com.b2b.admin.service.OrganizationServiceImpl.findById(OrganizationServiceImpl.java:28)
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:601)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy38.findById(Unknown Source)
My applicationContext.xml
Code:
<jee:jndi-lookup id="ecatalogAdminDS" jndi-name="java:/ecatalogAdminDS"></jee:jndi-lookup>
<jee:jndi-lookup id="ecatalogDS" jndi-name="java:/ecatalogDS"></jee:jndi-lookup>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
<tx:jta-transaction-manager transaction-manager="transactionManager"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="list*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="adminServiceMethods"
expression="execution(* com.b2b.admin.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="adminServiceMethods" />
</aop:config>
<bean id="ecatalogAdminSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="packagesToScan" value="com.b2b.security,com.b2b.admin"/>
<property name="hibernateProperties">
<ref bean="hibernateProperties" />
</property>
<property name="dataSource">
<ref local="ecatalogAdminDS" />
</property>
</bean>
<bean id="ecatalogSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="packagesToScan" value="com.b2b.security,com.b2b.admin"/>
<property name="hibernateProperties">
<ref bean="hibernateProperties" />
</property>
<property name="dataSource">
<ref local="ecatalogDS" />
</property>
</bean>
this is my hibernateProperties
Code:
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
#set this to avoid "cannot open connection" problem
hibernate.connection.release_mode=after_transaction
I hope i am giving enough informations.
I have been trying days to make it work.
Thank you in advance.