users@glassfish.java.net

EJB Timerservice

From: Theodor Richard <theodor.richard_at_googlemail.com>
Date: Fri, 2 Jul 2010 18:55:49 +0200

Hi all,

I have a problem with the Timerservice. I create a timer in my method as
follows:

timerService.createSingleActionTimer(timerDuration, new
TimerConfig(someInfo, true));

Everything seems to work (i.e. when I step over the code with the debugger,
I get a timer object back). But once the method finishes, I the transaction
is rolled back with the following exception:

Exception [EclipseLink-6168] (Eclipse Persistence Services -
2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred:
[java.lang.IndexOutOfBoundsException: Index: 0, Size: 0].
Internal Exception: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
Query: DoesExistQuery(referenceClass=TimerHandleImpl )
        at
org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1528)
        at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:521)
        at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:470)
        at
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:706)
        at
org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:643)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2909)
        at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1291)
        at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1273)
        at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1233)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.checkForUnregisteredExistingObject(UnitOfWorkImpl.java:763)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.discoverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:4166)
        at
org.eclipse.persistence.mappings.ObjectReferenceMapping.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectReferenceMapping.java:791)
        at
org.eclipse.persistence.mappings.ObjectReferenceMapping.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectReferenceMapping.java:769)
        at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.cascadeDiscoverAndPersistUnregisteredNewObjects(ObjectBuilder.java:1655)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.discoverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:4178)
        at
org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOfWork.java:225)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:701)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1512)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.issueSQLbeforeCompletion(UnitOfWorkImpl.java:3182)
        at
org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.issueSQLbeforeCompletion(RepeatableWriteUnitOfWork.java:268)
        at
org.eclipse.persistence.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:157)
        at
org.eclipse.persistence.transaction.JTASynchronizationListener.beforeCompletion(JTASynchronizationListener.java:68)
        at
com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:415)
        at
com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:842)
        at
com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5055)
        at
com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4834)
        at
com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2019)
        at
com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1970)
        at
com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:199)
        at
com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
        at $Proxy140.initiateAlert(Unknown Source)
        at
com.acme.enterpriseapp.alert.__EJB31_Generated__AlertService__Intf____Bean__.initiateAlert(Unknown
Source)
        at
com.acme.enterpriseapp.web.AlertController.create(AlertController.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
        at
com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
        at
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
        at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
        at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
        at javax.faces.component.UICommand.broadcast(UICommand.java:311)
        at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
        at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
        at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
        at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
        at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1518)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:171)
        at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:651)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:591)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:87)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158)
        at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:327)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:228)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:166)
        at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:803)
        at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:706)
        at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:987)
        at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:217)
        at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:526)
        at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:507)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at
org.eclipse.persistence.queries.DoesExistQuery.getDoesExistField(DoesExistQuery.java:244)
        at
org.eclipse.persistence.queries.DoesExistQuery.prepare(DoesExistQuery.java:305)
        at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:509)
        ... 72 more

It looks like there was a problem persisting the timer, but I have no idea
how that can happen.

Any help is very much appreciated.

Thanks,

Theo