3 Replies Latest reply on Apr 12, 2007 7:30 AM by Pete Muir

    No application context active when raising event

    Jarle Moen Newbie

      Hi,

      I get

      java.lang.IllegalStateException: No application context active
      when updating an @Entity from a MDB. The @Entity raise an event on the @PostUpdate. If commenting the call to raiseEvent everything works. It also works when updating the @Entity from the user interface and the event is raised.

      -A message is placed on a JMS queue which is picked up by a MDB (The MDB is a seam component).
      -The MDB make a call to a workhandler (also seam component) , which again ends up in updating an ARRIVAL through the Arrival Entity.
      -When Arrival is updated the following code is executed through @PostUpdate:
      @PostUpdate
       public void afterUpdate(Arrival entity)
       {
       Events.instance().raiseEvent("arrivalUpdate", entity);
       }

      -And this causes the following stacktrace:
      11:30:34,436 INFO [STDOUT] Hibernate:
       update
       ARRIVAL
       set
       ARR_ETA=?,
       ARR_PTA=?,
       ARR_ATA=?,
       COS_ID=?
       where
       ARR_ID=?
      11:30:34,451 ERROR [JmsServerSession] org.jboss.resource.adapter.jms.inflow.JmsServerSession@1b602b9 failed to commit/rollback
      org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=jarle/49, BranchQual=, localId=49] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: java.lang.IllegalStateException: No application context active)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession$XATransactionDemarcationStrategy.end(JmsServerSession.java:471)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:260)
       at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
       at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.persistence.PersistenceException: java.lang.IllegalStateException: No application context active
       at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
       ... 7 more
      Caused by: java.lang.IllegalStateException: No application context active
       at org.jboss.seam.Component.forName(Component.java:1577)
       at org.jboss.seam.Component.getInstance(Component.java:1627)
       at org.jboss.seam.Component.getInstance(Component.java:1622)
       at org.jboss.seam.Component.getInstance(Component.java:1599)
       at org.jboss.seam.Component.getInstance(Component.java:1594)
       at org.jboss.seam.core.Events.instance(Events.java:138)
       at com.logit.sailingplan.domain.ArrivalListener.afterUpdate(ArrivalListener.java:84)
       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:585)
       at org.hibernate.ejb.event.ListenerCallback.invoke(ListenerCallback.java:31)
       at org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:78)
       at org.hibernate.ejb.event.EntityCallbackHandler.postUpdate(EntityCallbackHandler.java:67)
       at org.hibernate.ejb.event.EJB3PostUpdateEventListener.onPostUpdate(EJB3PostUpdateEventListener.java:40)
       at org.hibernate.action.EntityUpdateAction.postUpdate(EntityUpdateAction.java:183)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:162)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
       at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
       ... 10 more


      -By commenting the raiseEvent it works and the Arrival is updated, but I'd like to have my event raised.

      -My @Observer for the Event is empty (just log)

      Anyone know what causes this behaviour? (I'm using seam 1.2.1.GA)

      Regards Jarle