3 Replies Latest reply on Oct 24, 2007 6:31 PM by Beaudoin Gaël

    IllegalArgumentException: Stack must not be null

    Beaudoin Gaël Newbie

      I've got this because I'm modifying an object managed by hibernate in an asynchronous method.
      Persisting new objects work fine though.

      The error occur after the method is run.

      I'm usins seam CVS.

      Any ideas ?

      here is the full stack :

      19:07:48,163 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@7a3f3b
      javax.persistence.PersistenceException: javax.el.ELException: java.lang.IllegalArgumentException: Stack must not be null
       at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
       at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
       at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
       at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
       at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
       at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
       at $Proxy1350.run(Unknown Source)
       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 org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
       at org.javassist.tmp.java.lang.Object_$$_javassist_11.run(Object_$$_javassist_11.java)
       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 org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
       at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52)
       at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
       at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
       at org.jboss.seam.async.ThreadPoolDispatcher$RunnableAsynchronous.run(ThreadPoolDispatcher.java:114)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
       at java.util.concurrent.FutureTask.run(FutureTask.java:138)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.el.ELException: java.lang.IllegalArgumentException: Stack must not be null
       at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:332)
       at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341)
       at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
       at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
       at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:174)
       at org.jboss.seam.core.Events.raiseEvent(Events.java:68)
       at org.jboss.seam.security.Identity.checkPermission(Identity.java:541)
       at org.jboss.seam.security.Identity.checkEntityPermission(Identity.java:705)
       at org.jboss.seam.security.EntitySecurityListener.preUpdate(EntitySecurityListener.java:44)
       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 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.preUpdate(EntityCallbackHandler.java:63)
       at org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:43)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:308)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:248)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:128)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
       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)
       ... 57 more
      Caused by: java.lang.IllegalArgumentException: Stack must not be null
       at org.jboss.seam.core.ConversationEntry.<init>(ConversationEntry.java:39)
       at org.jboss.seam.core.ConversationEntries.createConversationEntry(ConversationEntries.java:53)
       at org.jboss.seam.core.Manager.createConversationEntry(Manager.java:535)
       at org.jboss.seam.core.Manager.beginConversation(Manager.java:556)
       at org.jboss.seam.core.Conversation.reallyBegin(Conversation.java:223)
       at org.jboss.seam.core.Conversation.begin(Conversation.java:259)
       at org.jboss.seam.faces.Redirect.captureCurrentView(Redirect.java:109)
       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 org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
       ... 83 more


        • 1. Re: IllegalArgumentException: Stack must not be null
          Beaudoin Gaël Newbie

          Here is the class with some code removed as I think it's not relevant.

          When entityManager.merge is uncommented, the above exception ocurs.

          @Stateless
          @Name("importRunAction")
          public class ImportRunAction implements ImportRunActionInterface {
          
           @In
           EntityManager entityManager;
          
           public ImportRunAction() {
           }
          
           @Override
           public void run(Import importRule, User user) {
          
           /*
           * Asynchronous and ongoing task progress reporting
           */
           AsynchronousImportController aip = (AsynchronousImportController) Component
           .getInstance("asynchronousImportController");
           Progress progress = aip.getProgress(importRule);
          
           try {
          
          [...]
           importRunEvent.setMessage("Success");
           importRunEvent.end();
           entityManager.persist(importRunEvent);
           }
          
           } catch (Exception e) {
           FacesMessages.instance().add(e.getMessage());
           e.printStackTrace();
           aip.remove(importRule);
           }
          
           aip.remove(importRule);
          
           datasource.setBookCount(bookCount);
          
          // entityManager.merge(datasource);
          
           System.out.println("end run");
           }
          }


          • 2. Re: IllegalArgumentException: Stack must not be null
            Pete Muir Master

            You omitted so much code we can't see where datasource is created.

            • 3. Re: IllegalArgumentException: Stack must not be null
              Beaudoin Gaël Newbie

              well, indeed.Here is the complete asynchronous method :

              @Stateless
              36 @Name("importRunAction")
              37 public class ImportRunAction implements ImportRunActionInterface {
              38
              39 @In
              40 EntityManager entityManager;
              41
              42 public ImportRunAction() {
              43 }
              44
              45 @Override
              46 public void run(Import importRule, User user) {
              47
              48 int bookCount = 0;
              49 boolean success = true;
              50 File passthroughData = null;
              51 Datasource datasource = importRule.getDataSource();
              52
              53 List<Object> passthroughMetaData = null;
              54 List<MicroStepAction> microActions = new ArrayList<MicroStepAction>();
              55
              56 Collection<DataType> previousDataType;
              57 previousDataType = new ArrayList<DataType>();
              58 previousDataType.add(DataType.NONE);
              59
              60 Event importRunEvent = Tools.getNewEvent();
              61 importRunEvent.setUser(user);
              62 importRunEvent.setIsParent(true);
              63 importRunEvent.setObjectType(IMPORT);
              64 importRunEvent.setName(datasource.getName());
              65
              66 importRule.setStartDate(new Date(System.currentTimeMillis()));
              67
              68 /*
              69 * Asynchronous and ongoing task progress reporting
              70 */
              71 AsynchronousImportController aip = (AsynchronousImportController) Component
              72 .getInstance("asynchronousImportController");
              73 Progress progress = aip.getProgress(importRule);
              74
              75 try {
              76 for (MicroStep m : importRule.getMicroSteps()) {
              77 if (!m.isEnabled()) {
              78 continue;
              79 }
              80 if (!m.acceptInputDatas(previousDataType)) {
              81 FacesMessages.instance().addFromResourceBundle(
              82 "lrb.error.import.incorrectPreviousData");
              83 aip.remove(importRule);
              84 throw new Exception(
              85 m.getName()
              86 + " "
              87 + Tools
              88 .getTranslation("lrb.error.import.incorrectPreviousData"));
              89 }
              90 MicroStepAction msa = (MicroStepAction) Class.forName(
              91 "com.lrb.dataImport.microStepActions."
              92 + m.getClass().getSimpleName() + "Action")
              93 .newInstance();
              94 msa.setProgress(progress);
              95 microActions.add(msa);
              96 msa.setMicroStep(m);
              97 msa.setInputData(passthroughData);
              98 msa.setInputMetaData(passthroughMetaData);
              99
              100 /* Add all the parameters */
              101 msa.addParameter("user", user);
              102 msa.addParameter("datasource", datasource);
              103 msa.addParameter("table", importRule.getDataSource()
              104 .getTableName());
              105
              106 /* Actually run the microStepAction */
              107 success = success && msa.run();
              108
              109 msa.getEvent().setName(
              110 datasource.getName() + ":" + msa.getEvent().getName());
              111 importRunEvent.addChild(msa.getEvent());
              112
              113 if (success) {
              114 passthroughData = msa.getOutputData();
              115 passthroughMetaData = msa.getOutputMetadata();
              116 previousDataType = m.getOutputDataType();
              117
              118 // extract the number of rows
              119 Object parameter = msa.getParameter("rowCount");
              120 if (parameter != null && parameter instanceof Integer) {
              121 bookCount = (Integer) parameter;
              122 if (bookCount > 0) {
              123 datasource.setBookCount(bookCount);
              124 }
              125 }
              126 } else {
              127 FacesMessages.instance().addFromResourceBundle("lrb.error.import.failed");
              128 importRunEvent.setMessage("Failure");
              129 importRunEvent.end();
              130 entityManager.persist(importRunEvent);
              131 for (MicroStepAction action : microActions) {
              132 action.cleanUp();
              133 }
              134 aip.remove(importRule);
              135 throw new Exception(importRunEvent.getMessage());
              136 }
              137
              138 importRunEvent.setMessage("Success");
              139 importRunEvent.end();
              140 entityManager.persist(importRunEvent);
              141 }
              142
              143 } catch (Exception e) {
              144 FacesMessages.instance().add(e.getMessage());
              145 for (MicroStepAction msa : microActions) {
              146 msa.cleanUp();
              147 }
              148 e.printStackTrace();
              149 aip.remove(importRule);
              150 }
              151
              152 for (MicroStepAction msa : microActions) {
              153 msa.cleanUp();
              154 }
              155 aip.remove(importRule);
              156
              157 datasource.setBookCount(bookCount);
              158
              159 // TODO : find a way to make this work
              160 // entityManager.merge(datasource);
              161 }
              162 }