3 Replies Latest reply on Dec 12, 2009 8:46 AM by Nikolay Elenkov

    Exception on @Destroy for component with @Asynchronous annotation

    Sargis Harutyunyan Newbie
      Hi I have following exception:



      "20:07:17,279 INFO  [TomcatDeployment] undeploy, ctxPath=/miranda
      20:07:17,282 WARN  [Component] Exception calling component @Destroy method: ttXMLInboxScanner
      java.lang.NullPointerException
           at org.jboss.seam.async.AsynchronousInterceptor.isExecutingAsynchronousCall(AsynchronousInterceptor.java:63)
           at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:46)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
           at com.webbfontaine.miranda.timer.TTXMLInboxScanner_$$_javassist_seam_5.destroy(TTXMLInboxScanner_$$_javassist_seam_5.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:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
           at org.jboss.seam.Component.callDestroyMethod(Component.java:2180)
           at org.jboss.seam.Component.destroy(Component.java:1469)
           at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:251)
           at org.jboss.seam.contexts.Lifecycle.endApplication(Lifecycle.java:61)
           at org.jboss.seam.contexts.ServletLifecycle.endApplication(ServletLifecycle.java:149)
           at org.jboss.seam.servlet.SeamListener.contextDestroyed(SeamListener.java:41)
           at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3949)
           at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4615)
           at org.apache.catalina.core.ContainerBase.destroy(ContainerBase.java:1175)
           at org.apache.catalina.core.StandardContext.destroy(StandardContext.java:4705)
           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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
           at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
           at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performUndeployInternal(TomcatDeployment.java:596)
           at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performUndeploy(TomcatDeployment.java:570)
           at org.jboss.web.deployers.AbstractWarDeployment.stop(AbstractWarDeployment.java:480)
           at org.jboss.web.deployers.WebModule.stopModule(WebModule.java:133)
           at org.jboss.web.deployers.WebModule.stop(WebModule.java:102)
           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.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
           at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
           at $Proxy38.stop(Unknown Source)
           at org.jboss.system.microcontainer.StartStopLifecycleAction.uninstallAction(StartStopLifecycleAction.java:56)
           at org.jboss.system.microcontainer.StartStopLifecycleAction.uninstallAction(StartStopLifecycleAction.java:37)
           at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleUninstallAction(SimpleControllerContextAction.java:79)
           at org.jboss.dependency.plugins.action.AccessControllerContextAction.uninstall(AccessControllerContextAction.java:131)
           at org.jboss.dependency.plugins.AbstractControllerContextActions.uninstall(AbstractControllerContextActions.java:58)
           at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:354)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1664)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1275)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:827)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
           at org.jboss.system.ServiceController.stop(ServiceController.java:510)
           at org.jboss.system.deployers.ServiceDeployer.stop(ServiceDeployer.java:170)
           at org.jboss.system.deployers.ServiceDeployer.undeploy(ServiceDeployer.java:150)
           at org.jboss.system.deployers.ServiceDeployer.undeploy(ServiceDeployer.java:46)
           at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalUndeploy(AbstractSimpleRealDeployer.java:69)
           at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.undeploy(AbstractRealDeployer.java:112)
           at org.jboss.deployers.plugins.deployers.DeployerWrapper.undeploy(DeployerWrapper.java:196)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUndeploy(DeployersImpl.java:1469)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1376)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1369)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1356)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.uninstall(DeployersImpl.java:1331)
           at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:354)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1664)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1275)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:827)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:694)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679)
           at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
           at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
           at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
           at java.lang.Thread.run(Thread.java:619)
      20:07:17,339 INFO  [SessionFactoryImpl] closing
      20:07:17,347 INFO  [PersistenceUnitDeployment] Stopping persistence unit"




      Here is my component;



      `@Name("ttXMLInboxScanner")
      @Scope(ScopeType.APPLICATION)
      public class TTXMLInboxScanner {

          @Asynchronous
          public Future processFilesFromInbox(@Duration long duration, @IntervalDuration long interval) {

      }

          @Destroy
          public void destroy() {

          }


      }`



      Seems its bug in SEAM also please look at:

      http://www.seamframework.org/Community/AsynchronousInterceptorNullPointerOnDestroy

      There was such problem before but no any answer.
        • 1. Re: Exception on @Destroy for component with @Asynchronous annotation
          Nikolay Elenkov Master

          Event context is probably already destroyed at that point, hence the exception. File a JIRA, it might get fixed.


          Do you need to do something in the @Destroy method? (it is empty in the code above). If you might be able to fix it by providing your own asynchronous interceptor, instead of the default one. There are examples on the form how to customize installed interceptors if you decide to go that way.


          • 2. Re: Exception on @Destroy for component with @Asynchronous annotation
            Sargis Harutyunyan Newbie

            Hi Nikolay, in reality its not empty:




                @Destroy
                public void destroy() {
                    shutdowning = true;
                    log.info("Please trying to shutdown file processing thread pool...");
                    EXECUTOR.shutdown();
                    try {
                        boolean isDone = EXECUTOR.awaitTermination(30, TimeUnit.SECONDS);
                        if (!isDone) {
                            EXECUTOR.shutdownNow();
                        }
                    } catch (InterruptedException ignore) {
                    }
                }



            I want to do clean stuff for my class in ScopeType.APPLICATION scope.


            and the problem is here Seam:




               private boolean isExecutingAsynchronousCall()
               {
                   return Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);
               }
            



            and I know that Contexts.getEventContext() is null the question why? Because of I did wrong or its bug in Seam? I problem is is my code it means @Destroy annotation behavior
            should be document well because without it you need to try, have problem write in forum wait answer and etc.


            Thanks a lot for answer.


            Regards.


            • 3. Re: Exception on @Destroy for component with @Asynchronous annotation
              Nikolay Elenkov Master

              Probably a bug in Seam, nothing wrong with your code as far as I can see.