aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes javax. transaction. RollbackException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "javax. transaction. RollbackException" Watch "javax. transaction. RollbackException" New topic
Author

javax. transaction. RollbackException

Arijit Ghosh
Ranch Hand

Joined: Feb 01, 2002
Posts: 174
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 >

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

<enterprise-beans>

<!-- Session Beans -->
<session >
<description><![CDATA[The ClientManager Session Bean]]></description>
<display-name>Client Manager Session Bean</display-name>

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

<home>com.softex.itesoverseer.server.ejb.interfaces.ClientManagerHome</home>
<remote>com.softex.itesoverseer.server.ejb.interfaces.ClientManager</remote>
<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>

</session>

</enterprise-beans>

<!-- Assembly Descriptor -->
<assembly-descriptor >
<container-transaction>
<method>
<ejb-name>client/ClientManager</ejb-name>
<method-name>*</method-name>
</method>
<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">
<jboss>
<enterprise-beans>
<session>
<ejb-name>client/ClientManager</ejb-name>
<jndi-name>ejb/client/ClientManager</jndi-name>
</session>
</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>
</jboss>

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


Regards,<br /> Arijit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax. transaction. RollbackException