Rod,
If I have to write code to check that all cmp and cmr fields are correctly
set up at the end of ejbPostCreate, I could have checked carefully in
ejbCreate that this was happening already. So, this method is even more
error prone to my existing situation, i.e. if I am stupid enough not to
have initialised non-null deferrable fields in ejbCreate/PostCreate, then
I'll be stupid enough not to test the right fields in EJBObject too!
I'm hoping my client app can see an exception thrown and know that the
session bean method failed.
Ciao,
Jonathan O'Connor
Development Manager
XCOM Dublin
Phone: +353 1 872 3305
Mobile: +353 86 824 0736
Rod Macpherson <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
24.01.2003 14:02
Please respond to jboss-user
To: [EMAIL PROTECTED]
cc:
Subject: Re: [JBoss-user] Session Bean (Txn Required) commit error not
being sent
back to the client
Design artifact versus bug perhaps? You can call getEJBObject() at the end
of ejbPostCreate so you can validate your bean and throw a CreateException
if you have an illegal state.
----- Original Message -----
From: <Jonathan.O'[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 24, 2003 4:22 AM
Subject: [JBoss-user] Session Bean (Txn Required) commit error not being
sent back to the client
> Yesterday, we got bitten by the same bug that bit us last November.
Here's
> what happens:
> 1. A client app (JUnit tester) calls a method in a session bean (via
> remote interface). The method is marked as Transaction required.
> 1a. A transaction is started automatically by JBoss.
> 2. The session bean method creates an entity bean. Because we use
Oracle,
> we mark a foreign key field as NOT NULL DEFERRABLE INITIALLY DEFERRED.
> This means that the NOT NULL constraint is only checked at commit time,
> rather than at insert or update time.
> 3. The ejbCreate and ejbPostCreate of our entity bean don't call
> setFKField(), so this field remains NULL.
> 4. The code returns from the session bean method.
> 5. JBoss sees that the code has exited the session bean method marked as
> Txn Required, and tries to commit the Txn.
> 6. Oracle now kicks in, and checks all the deferred constraints.
Naturally
> one of them fails, so Oracle returns an exception saying the transaction
> has failed.
>
> Now for the bug:
> There is no place in my code where I can catch this XAException.
> Expected Result:
> The XAException should be turned into some sort of EJBException
> and returned to the caller of the session bean method.
>
> I'd be happy to provide a small test case for this, but it would use
> Oracle. I guess it is possible to get this bug using other databases,
but
> I think the SQL script would be DB specific.
>
> 2003-01-24 11:44:08,275 WARN [org.jboss.tm.TxCapsule] XAException:
> tx=XidImpl [FormatId=257, GlobalId=XCOM-IRL-JONATHAN//8, BranchQual=]
> errorCode=XA_UNKNOWN(0)
> javax.transaction.xa.XAException: could not commit local
> txjavax.resource.ResourceException: SQLException
> at
>
org.jboss.resource.connectionmanager.LocalTxConnectionManager$LocalConnectio
nEventListener.commit(LocalTxConnectionManager.java:567)
> at org.jboss.tm.TxCapsule.commitResources(TxCapsule.java:1714)
> at org.jboss.tm.TxCapsule.commit(TxCapsule.java:393)
> at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
> at
>
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:251)
> at
> org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:92)
> at
>
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:13
0)
> at
> org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
> at
>
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.jav
a:313)
> at org.jboss.ejb.Container.invoke(Container.java:712)
> at
> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
> at
>
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
> at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
> at sun.rmi.transport.Transport$1.run(Transport.java:148)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
> at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
> at
>
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:7
01)
> at java.lang.Thread.run(Thread.java:536)
> Ciao,
> Jonathan O'Connor
> Development Manager
> XCOM Dublin
> Phone: +353 1 872 3305
> Mobile: +353 86 824 0736
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user