1 Reply Latest reply on Aug 6, 2002 1:32 PM by Dain Sundstrom

    Transaction Rollback Exception

    Arijit Ghosh Newbie

      Hi,

      I'm using container managed transaction of Jboss 3.0 integrated with Tomcat 4.0.3. We are using the Struts framework and Castor.

      When i try to modify an existing object, the first time it works fine. the next time it throws the
      exception given below. Again the third time it works,4th time exception and so on..
      However if we try to modify different objects there is no problem.


      In the Deployment descriptor, ejb-jar.xml, <tran-attribute> under <assembly-descriptor> tag is set to "Required". We also tried using "RequiresNew".

      EJB-JAR.XML


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar >

      No Description.
      <display-name>Generated by XDoclet</display-name>

      <enterprise-beans>

      <!-- Session Beans -->

      <![CDATA[The PrivilegeManager Session Bean]]>
      <display-name>Client Manager Session Bean</display-name>

      <ejb-name>client/ClientManager</ejb-name>

      com.softex.itesoverseer.server.ejb.interfaces.ClientManagerHome
      com.softex.itesoverseer.server.ejb.interfaces.ClientManager
      <ejb-class>com.softex.itesoverseer.server.ejb.session.ClientManagerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <resource-ref>
      <res-ref-name>jdo/mydb</res-ref-name>
      <res-type>org.exolab.castor.jdo.DataObjects</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>




      <![CDATA[The PrivilegeManager Session Bean]]>
      <display-name>Privilege Manager Session Bean</display-name>

      <ejb-name>privilege/PrivilegeManager</ejb-name>

      com.softex.itesoverseer.server.ejb.interfaces.PrivilegeManagerHome
      com.softex.itesoverseer.server.ejb.interfaces.PrivilegeManager
      <ejb-class>com.softex.itesoverseer.server.ejb.session.PrivilegeManagerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <resource-ref>
      <res-ref-name>jdo/mydb</res-ref-name>
      <res-type>org.exolab.castor.jdo.DataObjects</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>



      <!--
      To add session beans that you have deployment descriptor info for, add
      a file to your merge directory called session-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Entity Beans -->

      <!--
      To add entity beans that you have deployment descriptor info for, add
      a file to your merge directory called entity-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Message Driven Beans -->
      <!--
      To add message driven beans that you have deployment descriptor info for, add
      a file to your merge directory called message-driven-beans.xml that contains
      the <message-driven></message-driven> markup for those beans.
      -->

      </enterprise-beans>

      <!-- Relationships -->

      <!-- Assembly Descriptor -->
      <assembly-descriptor >

      <container-transaction>

      <ejb-name>client/ClientManager</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>

      <!--
      <trans-attribute>Required</trans-attribute>
      -->

      </container-transaction>

      </assembly-descriptor>

      </ejb-jar>



      JBOSS.XML


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">



      <enterprise-beans>


      <ejb-name>client/ClientManager</ejb-name>
      <jndi-name>ejb/client/ClientManager</jndi-name>


      <ejb-name>privilege/PrivilegeManager</ejb-name>
      <jndi-name>ejb/privilege/PrivilegeManager</jndi-name>


      </enterprise-beans>

      <resource-managers>
      <resource-manager res-class="org.jboss.ejb.deployment.CastorJDOResource">
      <res-name>jdo/mydb</res-name>
      <res-jndi-name>java:/jdo/mydb</res-jndi-name>
      </resource-manager>
      <resource-manager res-class="org.jboss.ejb.deployment.CastorJDOResource">
      <res-name>jdo/mydb</res-name>
      <res-jndi-name>java:/jdo/mydb</res-jndi-name>
      </resource-manager>
      </resource-managers>










      Here is the code -

      ActionClass
      {


      //Actionclass calls the modifyClientDetails method of the session bean.

      clientManager.modifyClientDetails(oClientEntity);
      log.info("After calling modifyClientDetails in action");


      }catch (java.lang.reflect.UndeclaredThrowableException ex){
      //java.lang.reflect.UndeclaredThrowableException is thrown with an UndeclaredThrowable.
      //printint out getUndeclaredThrowable
      Throwable throwable = ex.getUndeclaredThrowable();
      log.error("STACK TRACE STARTS");
      log.error("ex.getUndeclaredThrowable",throwable);
      log.error("STACK TRACE ENDS");
      throw ex;
      }catch(Exception e) {
      log.error("Unexpected error ="+e.getMessage(),e);
      throw e;
      }
      }

      {

      //modifyClientDetails of Session bean. Calls the findByPrimaryKey method of helper class.
      public void modifyClientDetails(Client aClient) throws ApplicationException {
      ClientJDO clientJDO = null;
      System.out.println("in DAO "+aClient.getClientID());
      try {
      //retrieves object.
      clientJDO = (ClientJDO)castor.findByPrimaryKey(ClientJDO.class, new Long(aClient.getClientID()));
      //modifies properties of object.
      BeanUtils.populate(clientJDO,BeanUtils.describe(aClient));
      }
      catch (CastorException e) {
      throw new ApplicationException(e.getMessageKey(), e);
      }
      catch (Exception e) {
      throw new ApplicationException("error.apperror", e);
      }
      }


      {
      ......

      //method called in helper class - CastorMain
      public Object findByPrimaryKey(Class aClass, Object aKey) throws
      CastorException
      {
      OQLQuery findOql;
      Object aData try
      {
      db aData }
      catch(Exception e)
      {
      throw new CastorException("error.generalJDOError", e);
      }
      finally
      {
      try
      {
      if(db!= null) then db.close();
      log.debug("connection closed");
      }
      catch(PersistenceException e)
      {
      throw new CastorException("error.generalJDOError",e);
      }
      }
      return aData;
      }





      2002-08-01 20:16:27,960 INFO [com.softex.itesoverseer.server.servlet.action.ClientAction] Entered in Client Module
      2002-08-01 20:16:28,450 INFO [com.softex.itesoverseer.server.ejb.session.ClientManagerBean] before modify in Bean
      2002-08-01 20:16:28,510 DEBUG [com.softex.itesoverseer.server.ejb.dao.CastorMain] connection closed
      2002-08-01 20:16:28,510 INFO [com.softex.itesoverseer.server.ejb.session.ClientManagerBean] After modify in Bean
      2002-08-01 20:16:28,620 ERROR [com.softex.itesoverseer.server.servlet.action.ClientAction] STACK TRACE STARTS
      2002-08-01 20:16:28,950 ERROR [com.softex.itesoverseer.server.servlet.action.ClientAction] ex.getUndeclaredThrowable
      javax.transaction.RollbackException: Unable to commit, tx=XidImpl [FormatId=257, GlobalId=sham//14, BranchQual=] status=STATUS_ROLLEDBACK at
      org.jboss.tm.TxCapsule.commit(TxCapsule.java:389)
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:74)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:190)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:705)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:111)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy25.modifyClientDetails(Unknown Source)
      at com.softex.itesoverseer.server.servlet.action.ClientAction.execute(ClientAction.java:140)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:437)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:264)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1109)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:470)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
      at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
      at java.lang.Thread.run(Thread.java:484)
      2002-08-01 20:16:29,000 ERROR [com.softex.itesoverseer.server.servlet.action.ClientAction] STACK TRACE ENDS



      Thanks in advance