Hallo!
I'm using a user transaction in a stateless session Bean with BMT.
I have surround the utx.begin / utx.commit part with a "catch Throwable" thing.
But "utx.commit" throws a OptimisticLockException and its not caught.
What is wrong here?
@Stateless(name = "CatalogDAO", mappedName = "CatalogDAO")
@TransactionManagement(TransactionManagementType.BEAN)
public class CatalogDAO implements ICatalogDAO
{
[...]
private int updateCatalogItem(final CatalogItem catalogItem, int newItems) throws CatalogItemUpdateException
{
try
{
utx.begin();
[...]
utx.commit();
} catch (final NotSupportedException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final SystemException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final SecurityException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final IllegalStateException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final RollbackException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final HeuristicMixedException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final HeuristicRollbackException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
} catch (final OptimisticLockException e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
throw new CatalogItemUpdateException();
} catch (final oracle.toplink.essentials.exceptions.OptimisticLockException et)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
throw new CatalogItemUpdateException();
} catch (final Throwable e)
{
LOG.log(Level.SEVERE, "Problem in bean managed transaction", e);
throw new CatalogItemUpdateException();
}
return newItems;
}
}
Stacktrace:
[#|2009-04-21T18:57:01.315+0200|WARNING|sun-appserver9.1|oracle.toplink.essentials.session.file:/usr/share/glassfish-installer-v2ur2-b04/domains/domain1/applications/j2ee-apps/inbound-ear-1.2-SNAPSHOT/lib/inbound-stores-1.2-SNAPSHOT.jar-em1|_ThreadID=54;_ThreadName=DefaultQuartzScheduler_Worker-6;_RequestID=6ab105ee-2f2c-44b1-92af-94300bb298d0;|
javax.persistence.OptimisticLockException: Exception [TOPLINK-5006] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.OptimisticLockException
Exception Description: The object [...] cannot be updated because it has changed or been deleted since it was last read.
Class> de.epoq.inbound.stores.catalog.CatalogItem Primary Key> [244947]
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:405)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1126)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.issueSQLbeforeCompletion(UnitOfWorkImpl.java:2443)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.issueSQLbeforeCompletion(RepeatableWriteUnitOfWork.java:202)
at oracle.toplink.essentials.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:131)
at oracle.toplink.essentials.transaction.JTASynchronizationListener.beforeCompletion(JTASynchronizationListener.java:91)
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:419)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:371)
at com.sun.enterprise.distributedtx.UserTransactionImpl.commit(UserTransactionImpl.java:197)
at de.epoq.inbound.impl.core.catalog.CatalogDAO.updateCatalogItem(CatalogDAO.java:395)
(...)
Caused by: Exception [TOPLINK-5006] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.OptimisticLockException
Exception Description: The object [NAME: Mannesmann Steckschl�ssel-Satz, Inhalt: 55 Teile / TENANT: autoteilestore] cannot be updated because it has changed or been deleted since it was last read.
Class> de.epoq.inbound.stores.catalog.CatalogItem Primary Key> [244947]
at oracle.toplink.essentials.exceptions.OptimisticLockException.objectChangedSinceLastReadWhenUpdating(OptimisticLockException.java:151)
at oracle.toplink.essentials.descriptors.VersionLockingPolicy.validateUpdate(VersionLockingPolicy.java:726)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1299)
at oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:91)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:390)
at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:109)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:138)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:110)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:309)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:195)
at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2657)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1044)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:403)
... 48 more
|#]
[Message sent by forum member 'iceandfire' (iceandfire)]
http://forums.java.net/jive/thread.jspa?messageID=343115