7 Replies Latest reply on Jan 10, 2008 11:46 PM by Tim Timson

    Unable to use @Asynchronous annotation on Glassfish server

    Tim Timson Newbie

      When I attempt to use the @Asynchronous annotation as described in the reference manual (section 17.1.1. Asynchronous methods) I receive an InstatiationException with the message "Could not instantiate Seam component: org.jboss.seam.core.dispatcher". I have narrowed down the issue as follows:

      Asynchronous method in interface SystemManager.java

       @Asynchronous
       public void asyncTest();


      Implemented in SystemManagerBean.java
       public void asyncTest(){
       System.out.println("This is a test of async method.");
       }


      Called from Manager.xhtml
      <br/><h:commandButton value="Call Async Test" action="#{systemManager.asyncTest}" />


      Dispatcher added to Components.xml
       <core:dispatcher/>


      I am using Seam 1.2.1 on a Glassfish server. I am able to use a commandButton to call other methods in the same bean from the same jsf page, but when I call the "asyncTest()" method I get the stack trace shown below.

      Any suggestions are appreciated.


      org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      javax.faces.el.EvaluationException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
      at javax.faces.component.UICommand.broadcast(UICommand.java:383)
      at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
      at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
      at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:53)
      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
      ...etc...

      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      at org.jboss.seam.Component.newInstance(Component.java:1740)
      at org.jboss.seam.Component.getInstance(Component.java:1643)
      at org.jboss.seam.Component.getInstance(Component.java:1610)
      at org.jboss.seam.Component.getInstance(Component.java:1589)
      at org.jboss.seam.Component.getInstance(Component.java:1584)
      at org.jboss.seam.core.Dispatcher.instance(Dispatcher.java:238)
      at org.jboss.seam.interceptors.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:26)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
      at org.javassist.tmp.java.lang.Object_$$_javassist_3.asyncTest(Object_$$_javassist_3.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 com.sun.el.parser.AstValue.invoke(AstValue.java:187)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
      ... 57 more
      Caused by: javax.naming.NameNotFoundException: No object bound for java:comp/env/mlm-ear-1.0/Dispatcher/local [Root exception is java.lang.NullPointerException]
      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:224)
      at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:337)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
      at org.jboss.seam.Component.instantiate(Component.java:1093)
      at org.jboss.seam.Component.newInstance(Component.java:1736)
      ... 75 more
      Caused by: java.lang.NullPointerException
      at com.sun.ejb.EJBUtils.resolveEjbRefObject(EJBUtils.java:296)
      at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:945)
      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
      ... 80 more
      #{systemManager.asyncTest}: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      javax.faces.FacesException: #{systemManager.asyncTest}: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
      at javax.faces.component.UICommand.broadcast(UICommand.java:383)
      at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
      at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
      at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:53)
      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
      at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
      at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
      ...etc...

      Caused by: javax.faces.el.EvaluationException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
      ... 56 more
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      at org.jboss.seam.Component.newInstance(Component.java:1740)
      at org.jboss.seam.Component.getInstance(Component.java:1643)
      at org.jboss.seam.Component.getInstance(Component.java:1610)
      at org.jboss.seam.Component.getInstance(Component.java:1589)
      at org.jboss.seam.Component.getInstance(Component.java:1584)
      at org.jboss.seam.core.Dispatcher.instance(Dispatcher.java:238)
      at org.jboss.seam.interceptors.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:26)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
      at org.javassist.tmp.java.lang.Object_$$_javassist_3.asyncTest(Object_$$_javassist_3.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 com.sun.el.parser.AstValue.invoke(AstValue.java:187)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
      ... 57 more
      Caused by: javax.naming.NameNotFoundException: No object bound for java:comp/env/mlm-ear-1.0/Dispatcher/local [Root exception is java.lang.NullPointerException]
      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:224)
      at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:337)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
      at org.jboss.seam.Component.instantiate(Component.java:1093)
      at org.jboss.seam.Component.newInstance(Component.java:1736)
      ... 75 more
      Caused by: java.lang.NullPointerException
      at com.sun.ejb.EJBUtils.resolveEjbRefObject(EJBUtils.java:296)
      at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:945)
      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
      ... 80 more
      executePhase(INVOKE_APPLICATION 5,com.sun.faces.context.FacesContextImpl@2e8c5c) threw exception
      javax.faces.FacesException: #{systemManager.asyncTest}: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.core.dispatcher
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:105)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
      ...etc...

        • 1. Re: Unable to use @Asynchronous annotation on Glassfish serv
          Pete Muir Master

          Do you have jboss-seam.jar declared as an ejb-module in your application.xml?

          • 2. Re: Unable to use @Asynchronous annotation on Glassfish serv
            Tim Timson Newbie

            I was not declaring jboss-seam.jar in application.xml so I resolved that and now a timer runs but it cannot find the EJB containing the @Asynchronous method (SystemManagerBean).

            Here is what is displayed when the timer runs (emphasis added)...

            EJB5018: An exception was thrown during an ejb invocation on [Dispatcher]
            javax.ejb.EJBException
            at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3869)
            at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3769)
            at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
            at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
            at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
            at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:2855)
            at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1401)
            at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:99)
            at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:1952)
            at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.service(EJBTimerService.java:1948)
            at com.sun.ejb.containers.util.WorkAdapter.doWork(WorkAdapter.java:75)
            at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
            Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: systemManager
            at org.jboss.seam.Component.newInstance(Component.java:1740)
            at org.jboss.seam.Component.getInstance(Component.java:1643)
            at org.jboss.seam.Component.getInstance(Component.java:1610)
            at org.jboss.seam.Component.getInstance(Component.java:1604)
            at org.jboss.seam.core.Dispatcher$AsynchronousInvocation.call(Dispatcher.java:122)
            at org.jboss.seam.core.Dispatcher$Asynchronous.execute(Dispatcher.java:88)
            at org.jboss.seam.core.Dispatcher.dispatch(Dispatcher.java:165)
            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.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
            at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
            at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
            at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:2824)
            ... 6 more
            Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/mlm-ear-1.0/SystemManagerBean/local
            at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:834)
            at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
            at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:337)
            at javax.naming.InitialContext.lookup(InitialContext.java:392)
            at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
            at org.jboss.seam.Component.instantiate(Component.java:1093)
            at org.jboss.seam.Component.newInstance(Component.java:1736)
            ... 20 more
            EJB5119:Expunging timer ['4@@1198695363541@@server@@domain1' 'TimedObject = Dispatcher' 'Application = mlm-ear-1.0' 'BEING_DELIVERED' 'SINGLE-ACTION' 'Container ID = 78557698959015936' 'Wed Dec 26 11:57:02 MST 2007' '0' ] after [2] failed deliveries


            I declare the SystemManagerBean as follows:

            @Name(value = "systemManager")
            @Stateless
            public class SystemManagerBean implements SystemManager {
            

            I made a guess thinking it might be a glassfish embedded EJB issue and added the following to ejb-jar.xml but it did not help.
            <session>
             <ejb-name>Dispatcher</ejb-name>
             <ejb-local-ref>
             <ejb-ref-name>mlm-ear-1.0/SystemManagerBean/local</ejb-ref-name>
             <ejb-ref-type>Session</ejb-ref-type>
             <local>com.el.mlm.SystemManager</local>
             <ejb-link>SystemManagerBean</ejb-link>
             </ejb-local-ref>
             </session>


            Thanks for your help.

            • 3. Re: Unable to use @Asynchronous annotation on Glassfish serv
              Pete Muir Master

              You need the ejb declared in web.xml as well (see the jee5 example)

              • 4. Re: Unable to use @Asynchronous annotation on Glassfish serv
                Tim Timson Newbie

                I tried putting an entry for both "Dispatcher" and "SystemManager" in web.xml but still get the same error. I don't understand why a web.xml entry would be necessary since timers run in the EJB container but I tried it just the same. Does the ejb-local-ref definition for the Dispatcher look correct? I'm just guessing on that one in both web.xml and ejb-jar.xml.

                Here are the web.xml entries that I added:

                <ejb-local-ref>
                 <ejb-ref-name>mlm-ear-1.0/Dispatcher/local</ejb-ref-name>
                 <ejb-ref-type>Session</ejb-ref-type>
                 <local>org.jboss.seam.core.LocalDispatcher</local>
                 <ejb-link>Dispatcher</ejb-link>
                 </ejb-local-ref>
                
                 <ejb-local-ref>
                 <ejb-ref-name>mlm-ear-1.0/SystemManagerBean/local</ejb-ref-name>
                 <ejb-ref-type>Session</ejb-ref-type>
                 <local>com.el.mlm.SystemManager</local>
                 <ejb-link>SystemManagerBean</ejb-link>
                 </ejb-local-ref>
                



                • 5. Re: Unable to use @Asynchronous annotation on Glassfish serv
                  Tim Timson Newbie

                  Why would I need to declare ejb dependencies for a timer in web.xml? My understanding is that timers run in the ejb container, not the web container.

                  I've performed a search on all files underneath the jboss-seam-1.2.1.GA\examples directories and the two samples which use @Asynchronous (mail and seampay) do not declare any ejb dependencies. Is the "jee5 example" you mention found someplace else?

                  • 7. Re: Unable to use @Asynchronous annotation on Glassfish serv
                    Tim Timson Newbie

                    No, I couldn't get it to work so I ended up creating an EJB Timer to complete my task.
                    I would like to get it working with @Asynchronous if you have some more ideas for me.