Results 1 to 3 of 3

Thread: Wrong transaction association TransactionImpl XidImpl

  1. #1
    Join Date
    Aug 2004
    Location
    pleasanton, ca
    Posts
    4

    Default Wrong transaction association TransactionImpl XidImpl

    I'm getting a rather strange exception and am not sure where to look to resolve it so I would appreciate any leads.

    When I try calling a Hibernate DAO to 'create' an object in the database I'm getting an IllegalStateExcception with the text "Wrong transaction association: expected TransactionImpl:XidImpl [FormatId=257, GlobalId=my-url//3963, BranchQual=] was TransactionImpl:XidImpl [FormatId=257, GlobalId=my-url//3967, BranchQual=]"

    Here's the stack trace if that's useful:
    [junit] Create Messages:
    [junit] () DEBUG - No session found in the application context. No session ID will be passed for the front controller invocation.
    [junit] () DEBUG - Trying to create reference to an EJB
    [junit] () DEBUG - Obtained reference to remote EJB [ejb/FrontController:Stateless]
    [junit] () DEBUG - Method of remote EJB [ejb/FrontController] threw exception
    [junit] java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    [junit] java.rmi.ServerException: RuntimeException; nested exception is:
    [junit] java.lang.IllegalStateException: Wrong transaction association: expected TransactionImpl:XidImpl [FormatId=257, GlobalId=bcrawford-linux.transdyn.com//4327, BranchQual=] was TransactionImpl:XidImpl [FormatId=257, GlobalId=bcrawford-linux.transdyn.com//4331, BranchQual=]
    [junit] at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:292)
    [junit] at sun.rmi.transport.Transport$1.run(Transport.java:1 48)
    [junit] at java.security.AccessController.doPrivileged(Native Method)
    [junit] at sun.rmi.transport.Transport.serviceCall(Transport. java:144)
    [junit] at sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:460)
    [junit] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:701)
    [junit] at java.lang.Thread.run(Thread.java:534)
    [junit] at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(StreamRemoteCall.java:247)
    [junit] at sun.rmi.transport.StreamRemoteCall.executeCall(Str eamRemoteCall.java:223)
    [junit] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:1 33)
    [junit] at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub. invoke(Unknown Source)
    [junit] at org.jboss.invocation.jrmp.interfaces.JRMPInvokerPr oxy.invoke(JRMPInvokerProxy.java:135)
    [junit] at org.jboss.invocation.InvokerInterceptor.invoke(Inv okerInterceptor.java:96)
    [junit] at org.jboss.proxy.TransactionInterceptor.invoke(Tran sactionInterceptor.java:46)
    [junit] at org.jboss.proxy.SecurityInterceptor.invoke(Securit yInterceptor.java:45)
    [junit] at org.jboss.proxy.ejb.StatelessSessionInterceptor.in voke(StatelessSessionInterceptor.java:100)
    [junit] at org.jboss.proxy.ClientContainer.invoke(ClientConta iner.java:85)
    [junit] at $Proxy5.handle(Unknown Source)
    [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    [junit] at java.lang.reflect.Method.invoke(Method.java:324)
    [junit] at com.transdyn.dynac.framework.ejb.access.AgnosticSl sbInvokerInterceptor.invokeBeanMethod(Unknown Source)
    [junit] at com.transdyn.dynac.framework.ejb.access.AgnosticSl sbInvokerInterceptor.invoke(Unknown Source)
    [junit] at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    [junit] at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
    [junit] at $Proxy1.handle(Unknown Source)
    [junit] at com.transdyn.dynac.remoting.FrontControllerInvoker Interceptor.invoke(Unknown Source)
    [junit] at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    [junit] at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
    [junit] at $Proxy4.createMessageMultiString(Unknown Source)
    [junit] at com.transdyn.dynac.device.signs.ntcip.VariableMess ageSignIntegrationTest.testCreateMessageMultiStrin gs(Unknown Source)
    [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    [junit] at java.lang.reflect.Method.invoke(Method.java:324)
    [junit] at junit.framework.TestCase.runTest(TestCase.java:154 )
    [junit] at junit.framework.TestCase.runBare(TestCase.java:127 )
    [junit] at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    [junit] at junit.framework.TestResult.runProtected(TestResult .java:124)
    [junit] at junit.framework.TestResult.run(TestResult.java:109 )
    [junit] at junit.framework.TestCase.run(TestCase.java:118)
    [junit] at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    [junit] at junit.framework.TestSuite.run(TestSuite.java:203)
    [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnit TestRunner.run(JUnitTestRunner.java:289)
    [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnit TestRunner.main(JUnitTestRunner.java:523)
    [junit] Caused by: java.rmi.ServerException: RuntimeException; nested exception is:
    [junit] java.lang.IllegalStateException: Wrong transaction association: expected TransactionImpl:XidImpl [FormatId=257, GlobalId=bcrawford-linux.transdyn.com//4327, BranchQual=] was TransactionImpl:XidImpl [FormatId=257, GlobalId=bcrawford-linux.transdyn.com//4331, BranchQual=]
    [junit] at org.jboss.ejb.plugins.LogInterceptor.handleExcepti on(LogInterceptor.java:361)
    [junit] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInt erceptor.java:195)
    [junit] at org.jboss.ejb.plugins.ProxyFactoryFinderIntercepto r.invoke(ProxyFactoryFinderInterceptor.java:122)
    [junit] at org.jboss.ejb.StatelessSessionContainer.internalIn voke(StatelessSessionContainer.java:331)
    [junit] at org.jboss.ejb.Container.invoke(Container.java:700)
    [junit] at sun.reflect.GeneratedMethodAccessor136.invoke(Unkn own Source)
    [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    [junit] at java.lang.reflect.Method.invoke(Method.java:324)
    [junit] at org.jboss.mx.capability.ReflectedMBeanDispatcher.i nvoke(ReflectedMBeanDispatcher.java:284)
    [junit] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanSe rverImpl.java:546)
    [junit] at org.jboss.invocation.jrmp.server.JRMPInvoker.invok e(JRMPInvoker.java:367)
    [junit] at sun.reflect.GeneratedMethodAccessor142.invoke(Unkn own Source)
    [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    [junit] at java.lang.reflect.Method.invoke(Method.java:324)
    [junit] at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:261)
    [junit] at sun.rmi.transport.Transport$1.run(Transport.java:1 48)
    [junit] at java.security.AccessController.doPrivileged(Native Method)
    [junit] at sun.rmi.transport.Transport.serviceCall(Transport. java:144)
    [junit] at sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:460)
    [junit] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:701)
    [junit] at java.lang.Thread.run(Thread.java:534)
    [junit] Caused by: java.lang.IllegalStateException: Wrong transaction association: expected TransactionImpl:XidImpl [FormatId=257, GlobalId=bcrawford-linux.transdyn.com//4327, BranchQual=] was TransactionImpl:XidImpl [FormatId=257, GlobalId=bcrawford-linux.transdyn.com//4331, BranchQual=]
    [junit] at org.jboss.ejb.plugins.TxInterceptorCMT.endTransact ion(TxInterceptorCMT.java:383)
    [junit] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTran sactions(TxInterceptorCMT.java:277)
    [junit] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxIn terceptorCMT.java:128)
    [junit] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(S ecurityInterceptor.java:118)
    [junit] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInt erceptor.java:191)
    [junit] ... 19 more

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    How are you specifying the Hibernate datasource?

  3. #3
    Join Date
    Aug 2004
    Location
    pleasanton, ca
    Posts
    4

    Default

    Since I posted this I have been able to isolate the problem, figure out what is causing the exception and resolve 2 out of 3 places where this was occuring. I'm not sure that my solution to the 2 instances is the "proper" way to resolve the problem, but here's where things are at the moment.

    The cause of the exception is essentially performing a transaction within a transaction. I have 3 transactions (create, delete and update) where I need to perform some minimal business logic before deciding whether the transaction should proceed or not, throwing a checked exception if it should not proceed.

    Before allowing a create there is a check to ensure that one entity in the incoming object is unique. To do this I am calling a different method in the same DAO that is in itself a read_only transaction. (This probably should be done differently). I didn't really want to push the actual Hibernate query to accomplish this down into the true Hibernate code, but I have not figured out any other way to resolve this one yet.

    Before allowing a delete or update there is a check on a different database object to verify that it does not have any instance of a many-to-one mapping to the instance being deleted or updated. Since the method being called on the DAO for that other database object doesn't really need to be a transaction I resolved those 2 problems by specifying transaction attributes of PROPAGATION_NOT_SUPPORTED on the secondary method.

    If anyone has comments on a better way to resolve any of these issues I would appreciate them as I admit to being a real novice in this area.

    Also, in answer to the previous post response here is the essential parts of the jboss-service.xml file that sets up the data source.
    <server>
    <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=dynacHibernateService,name =dynacHibernateService">
    <depends>jboss.jca:service=RARDeployer</depends>
    <depends>jboss.jca:service=LocalTxCM,name=jdbc/dynacDS</depends>
    <attribute name="MapResources">...</attribute>
    <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
    <attribute name="Datasource">java:/jdbc/dynacDS</attribute>
    <attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQL Dialect</attribute>
    <attribute name="UseOuterJoin">false</attribute>
    <attribute name="ShowSql">false</attribute>
    </mbean>
    </server>

    Also, as an aside to anyone reading this post in an attempt to resolve similar exceptions I would direct them to the JBoss forum. There are many posts there discussing this particular exception and how JBoss configuration may be involved.

Similar Threads

  1. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  2. Transaction rolling back - What's wrong ??
    By vaibhavkhattri in forum Data
    Replies: 5
    Last Post: Aug 16th, 2005, 04:42 AM
  3. Replies: 0
    Last Post: Jun 6th, 2005, 06:22 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Transaction pb Hibernate/MySQL
    By syluser in forum Data
    Replies: 2
    Last Post: Aug 28th, 2004, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •