Ok, I have changed the applicationContext.xml file to what I believe should be the correct setup for CMT managed transactions. Unfortunately, I still get an "Write outside a transaction ..." exception.
I would appreciate any comments on this setup or comments on what is missing. As I pointed out in my initial post, I could not find an example on how to do this, so every comment is helpful.
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:aop="http://www.springframework.org/schema/aop"
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.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- This is the configuration for container managed transactions -->
<bean id="pmf" class="com.signsoft.ibo.client.PersistenceManagerFactoryImpl" destroy-method="close">
<property name="connectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="connectionURL" value="jdbc:mysql://localhost:3306/cardb"/>
<property name="connectionInfoName" value="com.signsoft.ibo.dbsupport.mysql.MySqlDatabaseInfo"/>
<property name="connectionUserName" value="root"/>
<property name="optimistic" value="true"/>
<property name="logging" value="true"/>
<property name="nontransactionalRead" value="false"/>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
<bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="myServiceTarget" class="de.znt.service.MyServiceImpl">
<constructor-arg ref="pmf"/>
</bean>
<bean id="myService" parent="txProxyTemplate">
<property name="target" ref="myServiceTarget"/>
</bean>
</beans>
The Exception:
Code:
Exception in thread "main" org.springframework.remoting.RemoteAccessException: Cannot access remote service [MyEJB]; nested exception is java.rmi.ServerException: RuntimeException; nested exception is:
com.signsoft.ibo.core.services.impl.server.es.IBOJDOUserException: [IBO#2006] [RMI TCP Connection(58)-127.0.0.1] Write outside a transaction with nontransactional-write = false
NestedThrowables:
null
Caused by: java.rmi.ServerException: RuntimeException; nested exception is:
com.signsoft.ibo.core.services.impl.server.es.IBOJDOUserException: [IBO#2006] [RMI TCP Connection(58)-127.0.0.1] Write outside a transaction with nontransactional-write = false
NestedThrowables:
null
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:386)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:196)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
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:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
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:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.signsoft.ibo.core.services.impl.server.es.IBOJDOUserException: [IBO#2006] [RMI TCP Connection(58)-127.0.0.1] Write outside a transaction with nontransactional-write = false
NestedThrowables:
null
at com.signsoft.ibo.core.services.impl.server.es.ExceptionServiceImpl.createJDOException(Unknown Source)
at com.signsoft.ibo.core.services.impl.generics.os.GenericObjectStateServiceImpl.b(Unknown Source)
at com.signsoft.ibo.core.services.impl.generics.os.GenericObjectStateServiceImpl.a(Unknown Source)
at com.signsoft.ibo.core.services.impl.generics.os.GenericObjectStateServiceImpl.__makePersistentFirstPass(Unknown Source)
at com.signsoft.ibo.client.PersistenceManagerImpl.makePersistent(Unknown Source)
at de.znt.service.MyServiceImpl.storeCar(MyServiceImpl.java:70)
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:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy118.storeCar(Unknown Source)
at de.znt.ejbtest.MxBean.storeCar(MxBean.java:138)
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:585)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:54)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
... 24 more