2 Replies Latest reply on Feb 3, 2009 12:48 AM by tt tt

    lock when commit to multiple database

    Ivan Nik Newbie

      lock occured in ejb transaction when commit to 2 different databases simultaneously.
      as result: both database (data1 and data 2 are locked)

      but separately or not in transaction is ok.

      jboss 4.2.Hibernarte 3.2.5.ga


      ...
      @Stateless
      @Local(value = ProcessingLocal.class)
      public class ProcessingBean implements ProcessingLocal
      {
       @EJB(beanName = "Data1Bean", beanInterface = Data1Local.class)
       private Data1Local data1;
       @EJB(beanName = "Data2Bean", beanInterface = Data2Local.class)
       private Data2Local data2;
      
       public void test() throws Exception
       {
       Entity1 e1 = new Entity1();
       data1.merge(e1);
      
       Entity2 e2 = new Entity2();
       data2.merge(e2);
       }
      }
      
      


      data-ds.xml
      <datasources>
      
       <xa-datasource>
       <jndi-name>data1</jndi-name>
       <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>
       <xa-datasource-property name="IfxIFXHOST">serv1</xa-datasource-property>
       <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">100</xa-datasource-property>
       <xa-datasource-property name="PortNumber">6666</xa-datasource-property>
       <xa-datasource-property name="DatabaseName">data1</xa-datasource-property>
       <xa-datasource-property name="ServerName">main</xa-datasource-property>
       <xa-datasource-property name="User">informix</xa-datasource-property>
       <xa-datasource-property name="Password">informix</xa-datasource-property>
       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
      
       <min-pool-size>5</min-pool-size>
       <max-pool-size>1000</max-pool-size>
      
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter
       </exception-sorter-class-name>
      
       <metadata>
       <type-mapping>InformixDB</type-mapping>
       </metadata>
      
       </xa-datasource>
      
       <xa-datasource>
       <jndi-name>data2</jndi-name>
       <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>
       <xa-datasource-property name="IfxIFXHOST">serv1</xa-datasource-property>
       <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">100</xa-datasource-property>
       <xa-datasource-property name="PortNumber">6666</xa-datasource-property>
       <xa-datasource-property name="DatabaseName">data2</xa-datasource-property>
       <xa-datasource-property name="ServerName">main</xa-datasource-property>
       <xa-datasource-property name="User">informix</xa-datasource-property>
       <xa-datasource-property name="Password">informix</xa-datasource-property>
       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
      
       <min-pool-size>5</min-pool-size>
       <max-pool-size>1000</max-pool-size>
      
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter
       </exception-sorter-class-name>
      
       <metadata>
       <type-mapping>InformixDB</type-mapping>
       </metadata>
      
       </xa-datasource>
      
      </datasources>
      


      in unit 1
      persistence.xml
      
      <?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="data1" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/data1</jta-data-source>
       <properties>
       <property name="hibernate.show_sql" value="false"/>
       <property name="hibernate.format_sql" value="true"/>
       <property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       </properties>
       </persistence-unit>
      
      </persistence>
      
      


      in unit 2
      persistence.xml
      
      <?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="data2" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/data2</jta-data-source>
       <properties>
       <property name="hibernate.show_sql" value="false"/>
       <property name="hibernate.format_sql" value="true"/>
       <property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       </properties>
       </persistence-unit>
      
      </persistence>
      
      


        • 1. Re: lock when commit to multiple database
          Ivan Nik Newbie


          helped this parameters:

          <track-connection-by-tx/>
          <isSameRM-override-value>false</isSameRM-override-value>

          • 2. UT factory lookup failed UserTransaction
            tt tt Newbie

            org.springframework.transaction.CannotCreateTransactionException: JTA failure on begin; nested exception is javax.transaction.SystemException: java.lang.RuntimeException: UT factory lookup failed
            Caused by: javax.transaction.SystemException: java.lang.RuntimeException: UT factory lookup failed
            at org.jboss.tm.usertx.client.ClientUserTransaction.begin(ClientUserTransaction.java:128)
            at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:724)
            at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:681)
            at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
            at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630)
            at com.logsky.service.impl.TtLogServiceImpl$$EnhancerByCGLIB$$a1e6a1e0.getRemoteLogUser()
            at com.logsky.action.LoginAction.performAction(LoginAction.java:30)
            at com.ttsoft.action.TtAction.execute(TtAction.java:48)
            at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at com.ttsoft.base.filter.EncodingFilter.doFilter(EncodingFilter.java:43)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Thread.java:595)