From: Horváth András on
Hi all!

I have a strange problem, I can't solve. I have a J2EE application using
EJBs. Sometimes (it's non determinal :( ), when I use an entity bean
from a session bean (I call a getter method on it) I get an error:

2005-09-12 06:05:00,011 WARN [org.jboss.tm.TransactionImpl] Transaction
TransactionImpl:XidImpl[FormatId=257, GlobalId=iadd/27838, BranchQual=,
localId=27838] timed out. status=STATUS_ACTIVE
2005-09-12 06:08:12,007 ERROR [org.jboss.ejb.plugins.LogInterceptor]
TransactionRolledbackLocalException in method: public abstract long
com.astron.iadd.server.ejb.interfaces.entity.KDSZEventLocal.getBegin(),
causedBy:
javax.transaction.RollbackException: Already marked for rollback
TransactionImpl:XidImpl[FormatId=257, GlobalId=iadd/27838, BranchQual=,
localId=27838]
at
org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:602)
at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.register(EntitySynchronizationInterceptor.java:149)
at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:269)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at
org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:111)
at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:242)
at
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
at
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
at
org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:363)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:514)
at org.jboss.ejb.Container.invoke(Container.java:873)
at
org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:50)
at $Proxy296.getBegin(Unknown Source)
at
com.astron.iadd.server.ejb.beans.facade.KDSZManagerBean.getEvents(KDSZManagerBean.java:752)
at sun.reflect.GeneratedMethodAccessor438.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

After this the program works fine, but there is a warning in every five
minute after the error:

2005-09-12 03:55:33,925 WARN
[org.jboss.ejb.plugins.AbstractInstanceCache] Unable to passivate due to
ctx lock, id=944

It's strange to me, because when I use the "local" EJB, it's in the
memory already. So what's the problem with simply calling a getter
method on it? This problem only occours at this point of code, but it
doesn't differ from other entity-bean handlings.

// ...
Collection events = getKDSZEventLocalHome().findBy( begin, end, new
Long(type) );
Iterator it = events.iterator();
while ( it.hasNext() ) {
eventLocal = (KDSZEventLocal)it.next();
if ( eventLocal.getBegin() == 0 && ( eventLocal.getPlBegin() >= end
|| eventLocal.getPlEnd() < begin) ) continue;
// ...

regards
Andrew Horvath