7 Replies Latest reply on Feb 18, 2003 5:30 AM by Koen Maes

    javax. transaction. RollbackException

    Arijit Ghosh Newbie

      Hi,

      I'm using container managed transaction of Jboss 3.0 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 object1 for the first time, there is no problem. Then we modfy object2 for the first time, there is no problem. If we now try to modify the same first object i.e. object1 again for the 2nd time, exception is being thrown.

      First 2 set of codes are Deployment descriptor, ejb-jar.xml and Vendor specific file jboss.xml

      modifyClientDetails() is first called from Action class. This in turn calls the corresponding method in the clientManagerBean.The method in the Bean performs 2 calls, 1st calls findByPrimaryKey() defined in CastorMain. This performs database operation. 2nd, it calls populate() [which is not a database call]. findByPrimaryKey() in CastorMain
      performs the following oeration --
      db = dobj.getDatabase();
      aData = db.load(aClass, aKey);

      EXCEPTION is shown at the end.

      Error seems to be on the client side and not on the Server side.



      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 ClientManager 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>



      </enterprise-beans>

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

      <container-transaction>

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

      <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>

      </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-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;
      }
      }


      ClientManagerBean
      {

      //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);
      }
      }



      CastorMain
      {
      ......

      //method called in helper class - CastorMain
      public Object findByPrimaryKey(Class aClass, Object aKey) throws
      CastorException
      {
      OQLQuery findOql;
      Object aData
      try
      {
      db = dobj.getDatabase();
      aData = db.load(aClass, aKey);
      }
      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;
      }



      EXCEPTION


      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

      Regards,
      Arijit

        • 1. Re: javax. transaction. RollbackException
          Dain Sundstrom Master

          There is a open bug report on castor tx integration with jboss tx. I suggest you look there or ask a question in the EJB/JBoss forum, as I don't think anyone in this forum uses castor.

          • 2. Re: javax. transaction. RollbackException
            Arijit Ghosh Newbie

            Thanks for your reply. Any URL where I can look for related bugs ?

            • 3. Re: javax. transaction. RollbackException
              Dain Sundstrom Master

              I just remember seeing it in the bug reports at the jboss page on source forge, but I don't remember the number.

              • 4. Re: javax. transaction. RollbackException
                Ron Newbie

                I used the rooms example by Terry Child combined with the template example from the src
                distribution to try to get Castor working with MSSQL and Jboss-3.0.3.
                The rooms example was for 2.x so I modified it as best I could. The problem I am having
                is that I am getting a null _jdo object back from the jndi lookup. any help would be
                greatly appreciated.

                **************************************************************************************************
                ************ The Problem ****
                **************************************************************************************************

                The problem is that things look like they are bound correctly,
                but I get a null object back from the call to:
                _jdo = (DataObjects) compEnv.lookup("jdo/modelJDO"); in CastorHelper()

                *************************************************************************************************

                ****************************************************************************************
                Cleint code from CastorHelper:
                ****************************************************************************************

                import org.exolab.castor.jdo.DataObjects;
                public class CastorHelper implements java.io.Serializable {

                public DataObjects _jdo;

                public CastorHelper() {

                Context compEnv = (Context) iniCtx.lookup("java:comp/env");
                _jdo = (DataObjects) compEnv.lookup("jdo/modelJDO");
                if (_jdo = =null) {
                //********************** here is the problem ************************
                //_jdo is null even though I did not get any Naming exceptions or
                //any other kind of exceptions
                //****************************************************************
                }
                }
                }
                ****************************************************************************************
                ******** Here are the XDoclet entries that are in the ModelServiceBean ejb class ******
                ****************************************************************************************

                * @ejb:resource-ref res-name="jdo/modelJDO"
                * res-type="org.exolab.castor.jdo.DataObjects"
                * res-auth="Container"
                *
                * @jboss:resource-ref res-ref-name="jdo/modelJDO"
                * resource-name="CastorModelJDO"
                *
                * @jboss:resource-manager res-man-class="org.jboss.ejb.deployment.CastorJDOResource"
                * res-man-name="CastorModelJDO"
                * res-man-jndi-name="java:/castorModel"
                *
                * @jboss:resource-manager res-man-class="org.jboss.ejb.deployment.JDBCResource"
                * res-man-name="jdbc/castorJDBCModel"
                * res-man-jndi-name="java:/jdbc/castorJDBCModel"


                ****************************************************************************************
                ********** ejb-jar.xml resulting from the above XDoclet tags.
                ****************************************************************************************
                -
                -
                - <![CDATA[ Provides services related to the administration of Models ModelServiceBean Session Bean ATTENTION: Some of the XDoclet tags are hidden from XDoclet by adding a "--" between @ and the namespace.
                ]]>

                <display-name>Model Service Bean</display-name>
                <ejb-name>test/ModelService</ejb-name>
                com.myco.ejb.interfaces.ModelServiceHome
                com.myco.ejb.interfaces.ModelService
                <ejb-class>com.myco.ejb.session.ModelServiceBean</ejb-class>
                <session-type>Stateful</session-type>
                <transaction-type>Container</transaction-type>
                - <resource-ref>
                <res-ref-name>jdo/modelJDO</res-ref-name>
                <res-type>org.exolab.castor.jdo.DataObjects</res-type>
                <res-auth>Container</res-auth>
                </resource-ref>



                ****************************************************************************************
                ********** jboss.xml resulting from the above XDoclet tags.
                ****************************************************************************************
                -
                - <enterprise-beans>
                -
                <ejb-name>test/ModelService</ejb-name>
                <jndi-name>ejb/test/ModelService</jndi-name>
                - <resource-ref>
                <res-ref-name>jdo/modelJDO</res-ref-name>
                <resource-name>CastorModelJDO</resource-name>
                </resource-ref>

                </enterprise-beans>
                - <resource-managers>
                - <resource-manager res-class="org.jboss.ejb.deployment.CastorJDOResource">
                <res-name>CastorModelJDO</res-name>
                <res-jndi-name>java:/castorModel</res-jndi-name>
                </resource-manager>
                - <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
                <res-name>jdbc/castorJDBCModel</res-name>
                <res-jndi-name>java:/jdbc/castorJDBCModel</res-jndi-name>
                </resource-manager>
                </resource-managers>




                ****************************************************************************************
                ********** mssql-xa-service.xml for establishing a DBConnection Pool with the Castor MBean at the end
                ****************************************************************************************



                <!-- For optional container managed security, include a login module
                configuration named MSSQLXaDbRealm in conf/login-conf.xml.
                Here is an example login module configuration for a ConfiguredIdentityLoginModule:

                <application-policy name = "MSSQLXaDbRealm">

                <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag ="required">
                <module-option name = "principal">yourprincipal</module-option>
                <module-option name = "userName">yourusername</module-option>
                <module-option name = "password">yourpassword</module-option>
                <module-option name = "managedConnectionFactoryName">jboss.jca:service=XATxCM,name=MSSQLXaDS</module-option>
                </login-module>

                </application-policy>

                NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
                module-option name = "managedConnectionFactoryName"
                must match the object name of the ConnectionManager you are configuring here.
                -->
                <!--uncomment this line if you are using the MSSQLXaDbRealm above
                MSSQLXaDbRealm
                -->

                <depends optional-attribute-name="ManagedConnectionFactoryName">
                <!--embedded mbean-->


                MSSQLXaDS

                <!--real attributes-->


                <config-property name="XADataSourceProperties" type="java.lang.String">ServerName=localhost;DatabaseName=testDB;SelectMethod=cursor</config-property>

                <config-property name="XADataSourceClass" type="java.lang.String">com.microsoft.jdbcx.sqlserver.SQLServerDataSource</config-property>


                <!--hack-->
                <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=Minerva JDBC XATransaction ResourceAdapter



                <depends optional-attribute-name="ManagedConnectionPool">
                <!--embedded mbean-->


                0
                50
                5000
                15
                <!--criteria indicates if Subject (from security domain) or app supplied
                parameters (such as from getConnection(user, pw)) are used to distinguish
                connections in the pool. Choices are
                ByContainerAndApplication (use both),
                ByContainer (use Subject),
                ByApplication (use app supplied params only),
                ByNothing (all connections are equivalent, usually if adapter supports
                reauthentication)-->
                ByContainer


                <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager


                <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager

                java:/TransactionManager

                <!--make the rar deploy! hack till better deployment-->
                jboss.jca:service=RARDeployer



                file:../server/sms3/conf/database.xml
                java:/castorModel
                10000
                true
                false
                false



                ****************************************************************************************
                ********** database.xml specified in the MBean above references the MSSQLXaDS bound above
                ****************************************************************************************






                ****************************************************************************************
                ********** jndi bindings printed at runtime before
                ********** I invoke _jdo = (DataObjects) compEnv.lookup("jdo/modelJDO"); in CastorHelper()
                ****************************************************************************************
                15:35:38,307 INFO [STDOUT] CastorHelper(): binding for: java
                15:35:38,307 INFO [STDOUT] MSSQLXaDS: org.jboss.resource.adapter.jdbc.JDBCDataSource:Reference Class Name: org.jboss.resource.adapter.jdbc.JDBCDataSource
                15:35:38,307 INFO [STDOUT] CastorHelper(): name: MSSQLXaDS
                15:35:38,307 INFO [STDOUT] CastorHelper(): object: Reference Class Name: org.jboss.resource.adapter.jdbc.JDBCDataSource
                .
                .
                .
                15:35:38,438 INFO [STDOUT] CastorHelper(): bindings for jdo
                15:35:38,438 INFO [STDOUT] CastorHelper(): binding for: jdo
                15:35:38,438 INFO [STDOUT] modelJDO: javax.naming.LinkRef:Reference Class Name: javax.naming.LinkRef
                Type: LinkAddress
                Content: java:/castorModel
                15:35:38,448 INFO [STDOUT] CastorHelper(): name: modelJDO
                15:35:38,448 INFO [STDOUT] CastorHelper(): object: Reference Class Name: javax.naming.LinkRef
                Type: LinkAddress
                Content: java:/castorModel

                **************************************************************************************************
                ************ The Problem ****
                **************************************************************************************************

                *** Notice that the objects are References to classes rather than actual objects ***

                *** So the problem is that things look like they are bound correctly,
                but I get a null object back from the call to:
                _jdo = (DataObjects) compEnv.lookup("jdo/modelJDO"); in CastorHelper()

                *************************************************************************************************




                • 5. Re: javax. transaction. RollbackException
                  Ron Newbie

                  Hi,
                  I am not able to get the results you have seen because
                  I am having a basic problem setting up Castor to run
                  under JBoss. If you could please help me with this setup
                  I will try help you with you exception case.

                  Any help would be greatly appreciated.

                  The basic problem is that I am getting an null DataObjects
                  object back from jndi on JBoss when using a lookup from
                  an ejb.

                  ModelService is my EJB Session Bean.
                  I have a web service using apache axis that
                  accesses a local Service Broker that does a
                  lookup of the ejb bean using the ModelService
                  Name:

                  Object objRef = context.lookup("ejb/sms3/ModelService");

                  *** In the ejbCreate of ModelService, I create a
                  ModelServiceDao object. In the ModelServiceDao
                  constructor I create a CastorHelper object. In
                  Castor Helper constructor I try to create a
                  DataObjects using a lookup as follows:

                  Context compEnv = (Context) iniCtx.lookup("java:comp/env");
                  _jdo = (DataObjects) compEnv.lookup("jdo/modelJDO");

                  jdo/modelJDO is referenced in the ejb-jar as follows

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

                  *** jdo/modelJDO is mapped to a resourceManager in JBoss.xml under the name CastorModelJDO.
                  CastorModelJDO refers to the resource jndi name
                  Java:/castorModel that is defined in an mbean.

                  - <resource-ref>
                  <res-ref-name>jdo/modelJDO</res-ref-name>
                  <resource-name>CastorModelJDO</resource-name>
                  </resource-ref>
                  - <resource-manager res-class="org.jboss.ejb.deployment.CastorJDOResource"> ******* is this the right class????
                  <res-name>CastorModelJDO</res-name>
                  <res-jndi-name>java:/castorModel</res-jndi-name>
                  </resource-manager>

                  *** Here is the binding information for jdo/modelJDO

                  15:35:38,438 INFO [STDOUT] modelJDO: javax.naming.LinkRef:Reference Class Name: javax.naming.LinkRef
                  Type: LinkAddress
                  Content: java:/castorModel

                  *** In the MBean I define a castorJDO resource under the jndi name java:/castorModel as follows:


                  file:../server/sms3/conf/database.xml
                  java:/castorModel
                  ...

                  *** in the database.xml file I reference a MSSQL
                  DataSource as follows:



                  *** I have registered the MSSQL datasource in an
                  MBean as:


                  ...

                  So what's my problem (technically speaking :)


                  I hope this is more clear and concise.
                  Thanks again,

                  Ron

                  Below is my original explanation of this problem with
                  more complete file listings.

                  • 6. Re: javax. transaction. RollbackException
                    Ron Newbie

                    I figured it out. :) :) :)!!!

                    It was a naming thing with the mbean specifying the
                    CastorJDO. I changed it back to match the example
                    on the Jboss site (i.e. using the name parameter
                    and using castorModel rather than java:/castorModel
                    in the jndi name attribute) and it worked. Woo hoo!!!

                    Thanks,

                    Ron

                    • 7. Re: javax. transaction. RollbackException
                      Koen Maes Newbie

                      Hi,

                      I'm having the *exactly* same javax.transaction.RollbackException !

                      Did you find your way out of this ??
                      I doubt this being a castor-jboss integration bug from may2002 as suggested !

                      Your help would be *very* welcome...

                      rgds,

                      koen