Hello,
It seems that with 3.0RC2, calling home.remove(pk) while no bean exists with
this PK, generates a TransactionRolledbackException.
The NoSuchEntityException exception cannot be catched: the transaction is
rollbacked (and thus the exception seems to be wrapped *before*)
I suspect AbstractTxInterceptor.invokeNext to be guilty. As you can see
below, the call goes through the return getNext().invokeHome(mi) and, if a
RuntimeException occurs (our case), the transaction is rollbacked and (if
newTx = false) the transaction is wrapped in a
TransactionRolledbackException.
Why this behaviour? David or Bill, any idea?
protected Object invokeNext(boolean remoteInvocation, Invocation mi,
boolean newTx)
throws Exception
{
try {
if (remoteInvocation)
return getNext().invoke(mi);
else
return getNext().invokeHome(mi);
} catch (RuntimeException e) {
try {
if(mi.getTransaction() != null) {
mi.getTransaction().setRollbackOnly();
}
} catch (SystemException ex) {
log.error("invokeNext", ex);
} catch (IllegalStateException ex) {
log.error("invokeNext", ex);
}
RemoteException ex;
if (newTx) {
if (e instanceof NoSuchEntityException) {
// Convert NoSuchEntityException to a
NoSuchObjectException
// with the same detail.
ex = new NoSuchObjectException(e.getMessage());
ex.detail =
((NoSuchEntityException)e).getCausedByException();
throw ex;
}
// OSH: Should this be wrapped?
ex = new ServerException(e.getMessage());
} else
// We inherited tx: Tell caller we marked for rollback only.
ex = new TransactionRolledbackException(e.getMessage());
ex.detail = e;
throw ex;
} catch (RemoteException e) {
Cheers,
Sacha
Example:
Code:
(first try = TravelAgentBean:221)
// we first remove any existing customer with the same IDs
//
try { custhome.remove (new Integer (1)); } catch
(NoSuchEntityException ignored) {ignored.printStackTrace ();}
try { custhome.remove (new Integer (2)); } catch
(NoSuchEntityException ignored) {}
15:42:34,294 INFO [STDOUT] Creating Customers 1 and 2..
15:42:34,324 ERROR [LogInterceptor] TransactionRolledbackException,
causedBy:
javax.ejb.NoSuchEntityException: Entity not found: primaryKey=1
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityC
ommand.java:163)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityC
ommand.java:62)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.
java:489)
at
org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager
.java:410)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(
CachedConnectionInterceptor.java:314)
at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchron
izationInterceptor.java:283)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:147)
at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterce
ptor.java:193)
at
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.jav
a:107)
at
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterce
ptor.java:69)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
.java:96)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:167)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:12
9)
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
at org.jboss.ejb.Container.invoke(Container.java:706)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
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.HomeInterceptor.invoke(HomeInterceptor.java:176)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
at $Proxy141.remove(Unknown Source)
at
com.titan.travelagent.TravelAgentBean.buildSampleData(TravelAgentBean.java:2
21)
at java.lang.reflect.Method.invoke(Native Method)
at
org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulS
essionContainer.java:823)
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:12
9)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:147)
at
org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSess
ionInstanceInterceptor.java:266)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
.java:96)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:167)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
at
org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:
380)
at org.jboss.ejb.Container.invoke(Container.java:706)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
at sun.rmi.transport.Transport$1.run(Transport.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:7
06)
at java.lang.Thread.run(Thread.java:484)
15:42:34,694 ERROR [STDERR]
javax.transaction.TransactionRolledbackException: Entity not found:
primaryKey=1; nested exception is:
javax.ejb.NoSuchEntityException: Entity not found: primaryKey=1
15:42:34,704 ERROR [STDERR] javax.ejb.NoSuchEntityException: Entity not
found: primaryKey=1
15:42:34,714 ERROR [STDERR] at
org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityC
ommand.java:163)
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development