6 Replies Latest reply on Dec 21, 2007 7:34 AM by kukeltje

    Autostart process on JBoss start

    candersen

      Hello,

      is there a way to start a process automatically right after the start of the JBossAS? I am using jBPM 3.2.2 on a JBoss 4.2.0GA and deployed my process using the deployer of the jbpm-console.

      Regards

      Claus

        • 1. Re: Autostart process on JBoss start
          kukeltje

          Yes, use e.g. startupservlet or something like that.

          • 2. Re: Autostart process on JBoss start
            candersen

            Hello,

            thanks for the answer, it works, but not to the extent I like it to work. I wrote a class that should start my process, it looks like this:

            package myPackage.process;
            
            import java.io.IOException;
            
            import javax.servlet.Servlet;
            import javax.servlet.ServletConfig;
            import javax.servlet.ServletException;
            import javax.servlet.ServletRequest;
            import javax.servlet.ServletResponse;
            
            import org.jbpm.JbpmConfiguration;
            import org.jbpm.JbpmContext;
            
            public class ProzessStarter implements Servlet {
            
             public void init(ServletConfig config) throws ServletException {
            
             JbpmConfiguration jc = JbpmConfiguration.getInstance();
             JbpmContext jcx = jc.createJbpmContext();
             jc.startJobExecutor();
             jcx.newProcessInstance("MyProcess").signal();
             }
            
             public void destroy() {
             }
            
             public ServletConfig getServletConfig() {
             // TODO Auto-generated method stub
             return null;
             }
            
             public String getServletInfo() {
             // TODO Auto-generated method stub
             return null;
             }
            
             public void service(ServletRequest arg0, ServletResponse arg1)
             throws ServletException, IOException {
             // TODO Auto-generated method stub
            
             }
            }
            


            I added the servlet to the web.xml of the jbpm-console.war:

            <servlet>
             <servlet-name>ZKSStartupServlet</servlet-name>
             <servlet-class>dev.zksabfall.service.prozess.ProzessStarter</ servlet-class>
             <load-on-startup>2</load-on-startup>
             </servlet>
            


            It starts the process on startup of the server, but I have a timer in the first state the process goes into. The problem is now: The timer isn't fired, the process waits in the state.

            Am I missing something in the code of the servlet?

            • 3. Re: Autostart process on JBoss start
              candersen

              Sorry, the code in the web.xml looks like this:

              <servlet>
               <servlet-name>StartupServlet</servlet-name>
               <servlet-class>myPackage.process</servlet-class>
               <load-on-startup>2</load-on-startup>
               </servlet>
              


              • 4. Re: Autostart process on JBoss start
                candersen

                And sorry again, now it is correct:

                <servlet>
                 <servlet-name>StartupServlet</servlet-name>
                 <servlet-class>myPackage.process.ProzessStarter</servlet-class>
                 <load-on-startup>2</load-on-startup>
                 </servlet>
                


                • 5. Re: Autostart process on JBoss start
                  candersen

                  I found a "solution". When I add

                  jcx.close
                  

                  after signalling the process, it works.

                  Is this the correct way to do this?

                  Regards

                  Claus

                  • 6. Re: Autostart process on JBoss start
                    kukeltje

                    according to the docs it is...