10 Replies Latest reply on Jun 20, 2011 10:11 AM by sunil M

    jBPM-4.2 Remote API problem?

    Mark Roy Newbie

      In jBPM 4.1, using the following jbpm.cfg.xml in my simple test app worked:

      <jbpm-configuration>
       <import resource="jbpm.jbossremote.cfg.xml" />
      </jbpm-configuration>


      Since upgrading to 4.2, however, I now get a NPE:

      java.lang.NullPointerException
       at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.checkDb(ProcessEngineImpl.java:177)
       at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.buildProcessEngine(ProcessEngineImpl.java:170)
       at org.jbpm.api.Configuration.getProcessEngine(Configuration.java:161)
       at org.jbpm.test.JbpmTestCase.initialize(JbpmTestCase.java:81)
       at org.jbpm.test.JbpmTestCase.setUp(JbpmTestCase.java:76)
       at gov.faa.ato.esp.ReviewProcess.setUp(ReviewProcess.java:24)
       at junit.framework.TestCase.runBare(TestCase.java:132)
       at junit.framework.TestResult$1.protect(TestResult.java:110)
       at junit.framework.TestResult.runProtected(TestResult.java:128)
       at junit.framework.TestResult.run(TestResult.java:113)
       at junit.framework.TestCase.run(TestCase.java:124)
       at junit.framework.TestSuite.runTest(TestSuite.java:232)
       at junit.framework.TestSuite.run(TestSuite.java:227)
       at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
       at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


      I traced this to the fact the userCommandService is assigned null from the following:

      userCommandService = (CommandService) processEngineWireContext.get(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE);


      Is this a bug in 4.2, or are there some additional configuration requirements to use the remote API? (I did upgrade the server's db schema to 4.2)





        • 1. Re: jBPM-4.2 Remote API problem?
          Joram Barrez Master

          Probably you are missing

          <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />


          in your config. It should be automatically discovered when using jbpm.default.cfg.xml


          • 2. Re: jBPM-4.2 Remote API problem?
            Mark Roy Newbie

            My jbpm.cfg.xml under JBoss is:

            <?xml version="1.0" encoding="UTF-8"?>
            
            <jbpm-configuration jndi-name="java:/ProcessEngine">
            
             <import resource="jbpm.default.cfg.xml" />
             <import resource="jbpm.businesscalendar.cfg.xml" />
             <import resource="jbpm.tx.jta.cfg.xml" />
             <import resource="jbpm.jpdl.cfg.xml" />
             <import resource="jbpm.identity.cfg.xml" />
             <import resource="jbpm.jobexecutor.cfg.xml" />
             <import resource="jbpm.console.cfg.xml" />
            
            </jbpm-configuration>
            


            which imports jbpm.default.cfg.xml, but I explictly added

             <process-engine-context>
             <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
             </process-engine-context>
            


            I see this in server.log

            DEBUG [org.jbpm.jboss.internal.JbpmService] (main) JbpmService starting...
            DEBUG [org.jbpm.pvm.internal.cfg.ProcessEngineImpl] (main) jndi name java:/ProcessEngine is not bound
            DEBUG [org.jbpm.pvm.internal.wire.WireContext] (main) eagerly initializing org.jbpm.pvm.internal.id.DatabaseIdComposer
            DEBUG [org.jbpm.pvm.internal.wire.WireContext] (main) eagerly initializing org.jbpm.pvm.internal.jobexecutor.JobExecutor
            DEBUG [org.jbpm.pvm.internal.cfg.ProcessEngineImpl] (main) publishing jBPM ProcessEngine in jndi at java:/ProcessEngine
            


            so, that seems to be loaded, but I still get the same problem.

            It doesn't make sense to me that the database should be checked (checkDb()) locally (at the 'client side'), but I added DatabaseIdComposer to that jbpm.cfg.xml anyway. Same problem. The client side of the remote API doesn't necessarily have a connection to the database. Shouldn't checkDb() be executed at the remote (JBoss) end?







            • 3. Re: jBPM-4.2 Remote API problem?
              Jiemin Zhang Newbie

              I have the same problem. My client application runs problem-free with jbpm 4.1, but has problem with jbpm 4.2. I use the new database and updated GPD and the jbpm libraries.

              I can use RemoteCommandExecutor to communicate with the JBoss server. But I don't understand, why can't I get the Process Engine from the jbpm.jbossremote.cfg.xml?

              What does the problem mean with " java.lang.NullPointerException at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.checkDb" ?

              • 4. Re: jBPM-4.2 Remote API problem?
                Joram Barrez Master

                If I understand the problem correctly, than you have a process engine running on JBoss and you want to connect to it using a client app. Right?

                 

                The thing is that you can't use the same config for server and client side, as you said for yourself this will fail for the obvious reasons that you don't have local db connection.

                 

                Try to import the jbpm.jbossremote.cfg.xml in the client config.

                Or try to use the following construct:

                 

                <ejb-remote-command-service
                        initial-context-factory="org.jnp.interfaces.NamingContextFactory"
                        provider-url="jnp://localhost"
                        url-pkg-prefixes="org.jboss.naming:org.jnp.interfaces">
                      <retry-interceptor />
                    </ejb-remote-command-service>

                 

                 

                Now, it could be that this command service need to be named and that you need to replace the occurences of the command service in jbpm.tx.jta.cfg.xml  :

                 

                <command-service name="newTxRequiredCommandService">
                      <environment-interceptor policy="requiresNew" />
                      <retry-interceptor type="jta" />
                      <jta-transaction-interceptor policy="requiresNew" />
                    </command-service>

                • 5. Re: jBPM-4.2 Remote API problem?
                  Mark Roy Newbie

                  Here is my updated client jbpm.cfg.xml

                   

                  <

                   

                  jbpm-configuration>

                   

                   

                  <process-engine-context>

                   

                  <ejb-remote-command-service

                   

                  initial-context-factory=

                  "org.jnp.interfaces.NamingContextFactory"

                   

                  provider-url="jnp://localhost" url-pkg-prefixes="org.jboss.naming:org.jnp.interfaces">

                   

                  <retry-interceptor />

                   

                  </ejb-remote-command-service>

                   

                   

                  </process-engine-context>

                  </

                   

                  jbpm-configuration>

                   

                   

                  Attached is my JBoss server jbpm.cfg.xml. Same problem, no change.

                  • 6. Re: jBPM-4.2 Remote API problem?
                    Jiemin Zhang Newbie

                    Thanks a lot for the answer.

                     

                    I added the jboss remote configuration to the jbpm.cfg.xml for my client app. The jbpm.cf.xml looks as follows:

                     

                    <?xml version="1.0" encoding="UTF-8"?>
                    <jbpm-configuration>

                      <process-engine-context>
                        <repository-service />
                        <repository-cache />
                        <execution-service />
                        <history-service />
                        <management-service />
                        <task-service />
                        <identity-service />

                     

                        <ejb-remote-command-service
                            initial-context-factory="org.jnp.interfaces.NamingContextFactory"
                            provider-url="jnp://localhost:1099"
                            url-pkg-prefixes="org.jboss.naming:org.jnp.interfaces">
                          <retry-interceptor />
                        </ejb-remote-command-service>

                     

                      </process-engine-context>

                    </jbpm-configuration>

                     

                    The jbpm.tx.jta.cfg.xml in jbpm.jar (on JBoss) already contains the same construct you wrote about.

                     

                    My client app. has no problem with jbpm 4.1, but has problem with jbpm-4.2. As I reported, I use the current database schema, jbpm libraries and GPD. The Problem with

                    java.lang.NullPointerException at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.checkDb

                    is not resolved.

                    • 7. Re: jBPM-4.2 Remote API problem?
                      Joram Barrez Master

                      And what if you name your remote command service as 'txRequiredCommandService' ?

                       

                      The NPE happens because it can't find this command service in your config, so explicitely naming it could do the trick.

                      • 8. Re: jBPM-4.2 Remote API problem?
                        Mark Roy Newbie

                        Okay, I changed my client jbpm.cfg.xml to

                         

                        <

                         

                        jbpm-configuration>

                         

                        <process-engine-context>

                         

                        <repository-cache />

                         

                        <execution-service />

                         

                        <history-service />

                         

                        <management-service />

                         

                        <task-service />

                         

                        <identity-service />

                         

                        <ejb-remote-command-service name="txRequiredCommandService" initial-context-factory="org.jnp.interfaces.NamingContextFactory" provider-url="jnp://localhost" url-pkg-prefixes="org.jboss.naming:org.jnp.interfaces">

                         

                        </ejb-remote-command-service>

                         

                        <jbpm-configuration>

                         

                        (I copied the contents of jbpm.jbossremote.cfg.xml and added the name to the ejb-remote-command-service). It seems to work now.

                         

                        So, this is a bug/omission in jbpm.jbossremote.cfg.xml that was introduced when the call to checkDb() was added? Apparently no one else is using the remote configuration because it could not have worked for anyone?

                         

                        Thanks,

                        Mark

                        </process-engine-context>
                        <retry-interceptor />

                         

                        <repository-service />

                         

                        • 9. Re: jBPM-4.2 Remote API problem?
                          Joram Barrez Master

                          I guess that the bug is indeed introduced when the checkDb() was added. Since this operation is quite new, possibly people aren't using it yet...

                           

                          I added a Jira issue : https://jira.jboss.org/jira/browse/JBPM-2751

                          • 10. Re: jBPM-4.2 Remote API problem?
                            sunil M Newbie

                            Hi ..

                             

                            I have a similar kind of problem...

                            i am using jbpm4.4 and followed the above steps for the configuration..but still getting error..

                            this is how i am invoking..

                             

                             

                             

                             

                             

                            ProcessEngine processengine =

                            new Configuration().setResource("/resources/jbpm.cfg.xml").buildProcessEngine();

                            RepositoryService repositoryService = processengine.getRepositoryService();

                            ExecutionService executionService = processengine.getExecutionService();

                            ProcessInstance processInstance=executionService.startProcessInstanceByKey("LZM");

                             

                            here is the error...

                            org.jbpm.api.JbpmException: couldn't execute remote command: null
                                 org.jbpm.enterprise.internal.ejb.EjbRemoteCommandService.execute(EjbRemoteCommandService.java:71)
                                 org.jbpm.pvm.internal.processengine.ProcessEngineImpl.checkDb(ProcessEngineImpl.java:152)
                                 org.jbpm.pvm.internal.processengine.ProcessEngineImpl.<init>(ProcessEngineImpl.java:105)
                                 org.jbpm.pvm.internal.cfg.ConfigurationImpl.instantiateProcessEngine(ConfigurationImpl.java:100)
                                 org.jbpm.pvm.internal.cfg.ConfigurationImpl.buildProcessEngine(ConfigurationImpl.java:92)
                                 com.process.actions.IntiateAction.execute(IntiateAction.java:23)
                                 org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
                                 org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
                                 org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
                                 org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
                                 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                                 javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
                            

                             

                            Please help me ....