aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Exception in CMT - urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Exception in CMT - urgent" Watch "Exception in CMT - urgent" New topic
Author

Exception in CMT - urgent

tina kinger
Greenhorn

Joined: Nov 23, 2003
Posts: 8
Hi all,
I have two beans which have one-many relationship (unidirectional)
I want the primary key of both beans to be auto incremented.I have set the property for this in my descriptor.
But iam thrown some exception while creating the instance.
this is the exception thrown.
' Exception during rollback of transaction javax.transaction.SystemException: Heuristic hazard: (weblogic.jdbc.jts.Connection, HeuristicHazard, (javax.transaction.xa.XAException: General error: Warning: Some non-transactional changed tables could
n't be rolled back)) '
But when the auto increment property is not set and if i hard code the primary key it works fine.I don't understand what the problem might be.
Can anyone help me with this.And figure out where the problem is.
Thank You,
Tina.
[ December 02, 2003: Message edited by: tina kinger ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by tina kinger:
I want the primary key of both beans to be auto incremented.I have set the property for this in my descriptor.
But iam thrown some exception while creating the instance.

Without the exception that causes the rollback in the first place, it's hard to pin down the problem. First, can you explain which form of PK-generation you're using? Are you using Oracle sequences? A separate NEXT_ID table? Selecting the max ID plus one?
Here's what I assume is happening.
1. Your code calls ejbHome.create(...)
2. WL calls bean.ejbCreate(...)
3. WL tries to generate the PK, but an exception is thrown
4. WL wraps exception in EJBException and throws it
5. Transaction is rolled back
6. The non-transactional change of generating a new PK can't be rolled back
7. WL throws a *new* exception to tell you about 6
I recommend declaring that ejbCreate and ejbPostCreate throw SQLException so you can catch it directly. Otherwise, catch the EJBException coming from your home.create(...) call and paste the stacktrace here.
Hopefully this will get you going in the right direction. Otherwise post more info.
tina kinger
Greenhorn

Joined: Nov 23, 2003
Posts: 8
Thank u David.
I got the problem solved.
Previously i was using The generator type - named_sequence_table.
I modified it to sql_server , sice my backend is MySql.It works fine.
But still i don't understand why there was problem while using the other type.But in the database the table was updated with the incremented value.The exception was thrown when i created the instance for the other bean(the cmr field of the first bean).I used the transaction attribute 'Required' for both the beans.
Can u make out where i was wrong.
This was the exception thrown
<Exception during rollback of transaction 10:98420e1b7f28edb9: javax.transaction.SystemException: Heuristic hazard: (weblogic.jdbc.jts.Connection, HeuristicHazard, (javax.transaction.xa.XAException: General error: Warning: Some non-transactional changed tables couldn't be rolled back))
at weblogic.transaction.internal.ServerTransactionImpl.internalRollback(ServerTransactionImpl.java:345)
at weblogic.transaction.internal.ServerTransactionImpl.rollback(ServerTransactionImpl.java:311)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:258)
at kosmic.ejb.session.NetFacadeBean_3yqvnr_EOImpl.createTopic(NetFacadeBean_3yqvnr_EOImpl.java:107)
at kosmic.ejb.session.NetFacadeBean_3yqvnr_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:159)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)
at kosmic.ejb.session.NetFacadeBean_3yqvnr_EOImpl_WLStub.createTopic(Unknown Source)
at kosmic.util.EJBUtil.createTopic(EJBUtil.java:224)
at kosmic.forum.PostAction.perform(PostAction.java:47)
at org.apache.struts.action.Action.execute(Action.java:420)
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:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
>
[ December 02, 2003: Message edited by: tina kinger ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by tina kinger:
Thank u David.
But still i don't understand why there was problem while using the other type.But in the database the table was updated with the incremented value.The exception was thrown when i created the instance for the other bean(the cmr field of the first bean).I used the transaction attribute 'Required' for both the beans.

You're welcome. That's really odd that it was generating the PK from the table and then tossing an exception. I know that in WebLogic there is a setting to tell it when to perform the commit of the creation of an entity bean: before or after calling ejbPostCreate(...). Since you're creating two *related* entity beans, perhaps the container is getting confused somehow.
I know, not very technical or helpful, but that's a strange problem. I'm just glad that using the other PK generator worked for you.
 
Don't get me started about those stupid light bulbs.
 
subject: Exception in CMT - urgent