1 Reply Latest reply on Oct 1, 2008 1:20 AM by System Administrator

    Problems starting an asynchronous method at start up

    Darrell Wu Newbie

      Hi,


      I'm getting some errors when i try to schedule an asynchronous method at start up.
      I've tried using the @Startup annotation with a @Create method and I get the following errors



      16:38:43,515 ERROR [TimerImpl] Error invoking ejbTimeout: javax.ejb.EJBException: java.lang.NumberFormatException: For input string: ""
      16:39:11,062 ERROR [GeneralPurposeDatabasePersistencePlugin] Cannot deserialize
      java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.seam.async.AsynchronousInvocation
           at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:242)
           at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
           at org.jboss.invocation.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:109)
           at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
           at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
           at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
           at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
           at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.deserialize(GeneralPurposeDatabasePersistencePlugin.java:432)
           at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.selectTimers(GeneralPurposeDatabasePersistencePlugin.java:273)
           at org.jboss.ejb.txtimer.DatabasePersistencePolicy.listTimerHandles(DatabasePersistencePolicy.java:187)
           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.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
           at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
           at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:278)
           at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
           at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)
      16:39:11,062 ERROR [GeneralPurposeDatabasePersistencePlugin] Cannot deserialize
      java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.seam.async.AsynchronousInvocation
           at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
           at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:242)
           at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
           at org.jboss.invocation.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:109)
           at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
           at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
           at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
           at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
           at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.deserialize(GeneralPurposeDatabasePersistencePlugin.java:432)
           at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.selectTimers(GeneralPurposeDatabasePersistencePlugin.java:273)
           at org.jboss.ejb.txtimer.DatabasePersistencePolicy.listTimerHandles(DatabasePersistencePolicy.java:187)
           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.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
           at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
           at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:278)
           at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
           at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)
      






      I've also tried the @Observer(org.jboss.seam.postInitialization) method and this give me the following errors



      10:27:04,515 ERROR [TimerImpl] Error invoking ejbTimeout: javax.ejb.EJBException: java.lang.NumberFormatException: For input string: ""
      10:31:29,468 FATAL [RegularObjectPersister] error
      java.lang.reflect.InvocationTargetException
           at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithMethod(RegularObjectPersister.java:120)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:86)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.ObjectOutputStreamProxy.writeObjectOverride(ObjectOutputStreamProxy.java:60)
           at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:298)
           at EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList.writeObject(CopyOnWriteArrayList.java:772)
           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.jboss.serial.persister.RegularObjectPersister.writeSlotWithMethod(RegularObjectPersister.java:120)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:86)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:90)
           at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.ArrayPersister.saveObjectArray(ArrayPersister.java:110)
           at org.jboss.serial.persister.ArrayPersister.writeData(ArrayPersister.java:101)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.io.JBossObjectOutputStream.writeObjectOverride(JBossObjectOutputStream.java:181)
           at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:298)
           at org.jboss.serial.io.MarshalledObject.<init>(MarshalledObject.java:51)
           at org.jboss.ejb3.stateful.StatefulBeanContext.writeExternal(StatefulBeanContext.java:857)
           at org.jboss.serial.persister.ExternalizePersister.writeData(ExternalizePersister.java:58)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.io.JBossObjectOutputStream.writeObjectOverride(JBossObjectOutputStream.java:181)
           at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:298)
           at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:390)
           at org.jboss.ejb3.cache.simple.SimpleStatefulCache.passivate(SimpleStatefulCache.java:301)
           at org.jboss.ejb3.cache.simple.SimpleStatefulCache$SessionTimeoutTask.run(SimpleStatefulCache.java:209)
      Caused by: java.lang.NoClassDefFoundError: org/jaxen/VariableContext
           at java.lang.Class.getDeclaredMethods0(Native Method)
           at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
           at java.lang.Class.getDeclaredMethod(Class.java:1907)
           at org.jboss.serial.classmetamodel.ClassMetaData.lookupMethodOnHierarchy(ClassMetaData.java:102)
           at org.jboss.serial.classmetamodel.ClassMetaData.lookupInternalMethods(ClassMetaData.java:432)
           at org.jboss.serial.classmetamodel.ClassMetaData.<init>(ClassMetaData.java:122)
           at org.jboss.serial.classmetamodel.ClassMetamodelFactory.getClassMetaData(ClassMetamodelFactory.java:350)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:168)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.ArrayPersister.saveObjectArray(ArrayPersister.java:110)
           at org.jboss.serial.persister.ArrayPersister.writeData(ArrayPersister.java:101)
           at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
           at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
           at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(RegularObjectPersister.java:182)
           at org.jboss.serial.persister.ObjectOutputStreamProxy.writeFields(ObjectOutputStreamProxy.java:79)
           at org.jboss.serial.persister.ObjectOutputStreamProxy.defaultWriteObject(ObjectOutputStreamProxy.java:68)
           at java.util.Vector.writeObject(Vector.java:1018)
           ... 91 more




      the method I'm using at start up is



      //@Observer("org.jboss.seam.postInitialization")
      @Create
      public void startService() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, 5);
        Long repeat = 5* 60 * 1000L;
        try {
         billingTimer = billingAction.processRecurringBilling(cal.getTime(), repeat);
        } catch (Exception ex){
          ex.printStackTrace();
        }
      }







      The  local interface of billingAction is



      @Asynchronous
          public Timer processRecurringBilling(@Expiration Date date,
                                              @IntervalDuration Long interval);




      When I schedule the Asynchronous method through an action method from a web page I don't get the error and everything works fine.
      I'm using JBoss 4.2.3.GA and Seam 2.0.2.SP1 using the EJB3 timer.


      Does anyone have any ideas on what's wrong or how i can schedule a task at startup?


      Regards
      Darrell


        • 1. Re: Problems starting an asynchronous method at start up
          System Administrator Expert

          I didn't use @Startup but my code works with EJB 3 timer or Quartz scheduling...


          using Seam 2.0.1.GA and JBoss 4.2 (EAP 4.3.0CP2_FP01)


          components.xml:


            

          <event type="org.jboss.seam.postInitialization">   
                  <action execute="#{controller.scheduleTimer}"/>
             </event>
             
             <!-- Install the QuartzDispatcher -->
             <async:quartz-dispatcher/>   
            
             <!-- Install the EJB timer service -->  
             <!-- <async:timer-service-dispatcher />  -->



          controller component:


          @Name("controller")
          @AutoCreate
          public class ScheduleController implements Serializable { 
             
              @In ScheduleProcessor processor;    
              @Logger Log log;        
               private Map<String,List<UserItem>> map;     
               private String distinguishedNameShims;     
               private String distinguishedNameItJava;     
               private Timer timer;     
               private QuartzTriggerHandle quartzTriggerHandle;
               
              public void scheduleTimer()
              {                           
                   Long pollingInterval = null;
                            
                    String activeDirectoryPollingInterval = CoxProperties.getPropertyObject().getProperty(CoxConstants.ACTIVE_DIRECTORY_POLLING_INTERVAL);
                    if (activeDirectoryPollingInterval != null) {
                         pollingInterval = Long.valueOf(activeDirectoryPollingInterval);
                    }
                    
                    Boolean usingEjbTimer = Boolean.valueOf(CoxProperties.getPropertyObject().getProperty(CoxConstants.USING_EJB_TIMER)==null?"false":CoxProperties.getPropertyObject().getProperty(CoxConstants.USING_EJB_TIMER));          
                    distinguishedNameShims = CoxProperties.getPropertyObject().getProperty(CoxConstants.DISTINGUISHED_NAME_SHIMS);               
                              
                    if (usingEjbTimer) {                         
                         timer = processor.createEjbTimer(new Date(), pollingInterval, distinguishedNameShims);
                    }
                    else {
                         quartzTriggerHandle = processor.createQuartzTimer(new Date(), pollingInterval, distinguishedNameShims);
                    }
                  
              }
                          
              
              public Map<String, List<UserItem>> getMembersOfRoleMap(){
                   
                   //get the map from the application context of EJBPollingProcessorBean             
                   map = processor.getMap();
                            
                   return map;
              }
                   
               
          }



          processor component:


          @Name("processor")
          @AutoCreate
          @Scope(ScopeType.APPLICATION)
          public class ScheduleProcessor { 
              
               //TO DO: map needs to be stored in application context as it is session-independent data
               //TO DO: convert this into an ArrayList of map objects b/c we will need a map
               // for every drop-down in each app
              
              private List<UserItem> userItemList;
              
              private Map<String, List<UserItem>> map;
              
              @Logger Log log;
              
              //@In(create=true) TimerService timerService;
              
              //EJB Timer version...
              @Asynchronous
              @Transactional
              public Timer createEjbTimer(@Expiration Date when, @IntervalDuration Long interval, String distinguishedGroupName) 
              {            
                   process(when, interval, distinguishedGroupName);
                   
                   return null;
              }
              
              //Quartz version...
              @Asynchronous
              @Transactional
              public QuartzTriggerHandle createQuartzTimer(@Expiration Date when, @IntervalDuration Long interval, String distinguishedGroupName)
              {
                   process(when, interval, distinguishedGroupName);
                   
                   return null;
              }
              
              private void process(Date when, Long interval, String distinguishedGroupName) {
                   /*if(!cancelComplete) {
                         //cancel existing timers...
                        Collection collection = timerService.getTimers();
                        if (collection != null) {
                             Iterator it = collection.iterator();
                             while(it.hasNext()) {
                                  Timer timer = (Timer) it.next();
                                  timer.cancel();
                             }
                             cancelComplete = true;
                        }
                    }*/
                    
                    log.info("when = " + when);
                    log.info("interval = " + interval);
                    log.info("distinguishedGroupName = "+distinguishedGroupName);
                    
                    String searchBase = CoxProperties.getPropertyObject().getProperty(CoxConstants.ACTIVE_DIRECTORY_SEARCH_BASE);
                   String providerUrl = CoxProperties.getPropertyObject().getProperty(CoxConstants.ACTIVE_DIRECTORY_PROVIDER_URL);
                   String principal = CoxProperties.getPropertyObject().getProperty(CoxConstants.ACTIVE_DIRECTORY_USER);
                   String credentials = CoxProperties.getPropertyObject().getProperty(CoxConstants.ACTIVE_DIRECTORY_PWD);
               
                   // Declare holders search result's
                   SearchAdapterResult<UserItem> userSearchResults = null;        
                   
                   // Create a new instance of CADILS search adapter
                   SearchAdapter sa = new SearchAdapter(searchBase, providerUrl, principal, credentials);
               
                   try {
                         String groupSearchFilter = "*)(memberOf=" + distinguishedGroupName;   
                         userSearchResults = sa.searchBySAMAccountName(groupSearchFilter);
               
                         if (userSearchResults.hasItems()) {
                             //List of all the AD users who belong to your group
                              userItemList = userSearchResults.getItemList();
                              if (map == null) {
                                   map = new TreeMap<String, List<UserItem>>();
                              }
                              map.put(distinguishedGroupName, userItemList);
                         }
                   } 
                   catch (SearchFailedException sfe) {
                         log.error(sfe);
                   }
                   
              }
              
              
              public Map<String, List<UserItem>> getMap() {
                   return map;
              }
          }



          the polling interval is configured in foobar-config.properties.


          hope that helps.