1 Reply Latest reply on Jan 31, 2016 6:20 AM by salvuzzo

    java.lang.ClassNotFoundException: org.jbpm.services.task.commands.GetContentCommand

    salvuzzo

      Hello, i have a problem with started a process JBPM by an method of an Class with a method public static main. I have created a project JBPM with maven and this project have an bpmn with inside a start a script and end.Then this jar i deployed into jbpm-console (KIE Workbench)with deployed Units (groupId,Artifact and Version). Then, by my eclipse i invoked this process with a method public static and below my code java:

       

      public class Test {

       

          public static void main(String[] args) {

              try{

                 

                  String deploymentId = "richieste-portale:richieste-portale:1.0.0-SNAPSHOT";

                  URL appUrl = new URL("http://localhost:8080/jbpm-console/");

                  String user = "admin";

                  String password = "admin";

                          

                  new Test().startProcessAndHandleTaskViaRestRemoteJavaAPI(appUrl, deploymentId, user, password);

                 

              }catch(Exception e){

                  e.printStackTrace();

              }

          }

       

       

          public void startProcessAndHandleTaskViaRestRemoteJavaAPI(URL instanceUrl, String deploymentId, String user, String password) {

       

                RemoteRuntimeEngineFactory restSessionFactory  = new RemoteRestRuntimeFactory(deploymentId, instanceUrl, user, password);

       

                // Create KieSession and TaskService instances and use them

       

                RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();

       

                KieSession ksession = engine.getKieSession();

       

                TaskService taskService = engine.getTaskService();

       

                ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");

       

                long procId = processInstance.getId();

       

                String taskUserId = user;

                taskService = engine.getTaskService();

       

                List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(user, "en-UK");

       

                long taskId = -1;

                for (TaskSummary task : tasks) {

                  if (task.getProcessInstanceId() == procId) {

                    taskId = task.getId();

                  }

       

                }

       

                if (taskId == -1) {

                  throw new IllegalStateException("Unable to find task for " + user + " in process instance " + procId);

       

                }

                taskService.start(taskId, taskUserId);

              }

         

      }

       

      but i get this error:

       

      Exception in thread "main" java.lang.NoClassDefFoundError: org/jbpm/services/task/commands/GetContentCommand

          at org.kie.services.shared.AcceptedCommands.<clinit>(AcceptedCommands.java:106)

          at org.kie.services.client.api.command.AbstractRemoteCommandObject.execute(AbstractRemoteCommandObject.java:96)

          at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:242)

          at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:233)

          at com.sample.ProcessMain.startProcessAndHandleTaskViaRestRemoteJavaAPI(ProcessMain.java:198)

          at com.sample.ProcessMain.main(ProcessMain.java:63)

      Caused by: java.lang.ClassNotFoundException: org.jbpm.services.task.commands.GetContentCommand

          at java.net.URLClassLoader.findClass(Unknown Source)

          at java.lang.ClassLoader.loadClass(Unknown Source)

          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

          at java.lang.ClassLoader.loadClass(Unknown Source)

          ... 6 more

        • 1. Re: java.lang.ClassNotFoundException: org.jbpm.services.task.commands.GetContentCommand
          salvuzzo

          I have change method. Now my news code java is:

           

              String deploymentId = "test-jbpm:1.0.0-SNAPSHOT";
              URL appUrl = new URL("http://localhost:8080/jbpm-console");
              String user = "admin";
              String password = "admin";
            
            
              RemoteRestRuntimeFactory restSessionFactory
                  = new RemoteRestRuntimeFactory(deploymentId, appUrl, user, password);
              RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();
            
              KieSession ksession = engine.getKieSession();
              TaskService taskService = engine.getTaskService();
              AuditLogService auditLogService = engine.getAuditLogService();
            
              Map<String, Object> params = new HashMap<String, Object>();
              params.put("candidate", "johny");
            
              ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello", params);

           

           

          but now i get other error:


          SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

          Exception in thread "main" java.lang.NullPointerException

              at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:416)

              at org.kie.services.client.api.command.AbstractRemoteCommandObject.execute(AbstractRemoteCommandObject.java:120)

              at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:230)

              at com.sample.ProcessMain.main(ProcessMain.java:75)