ClassNotFoundException(Throwable)。<init>(String,Throwable)</init>

时间:2014-12-26 13:29:49

标签: jbpm bpmn

当我尝试启动bpmn2进程时,我得到ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286

我还没有找到解决方案。有人可以帮忙吗?

详细说明:

我的代码:

 KnowledgeBase kbase = readKnowledgeBase();
    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

    MyTaskHandler myTaskHandler = new MyTaskHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("myservice",myTaskHandler);
    System.out.println("Registeredddddddddddddd");
    ***ksession.startProcess("SingleNode_Process");***

在调试了kie和drools的源代码库后,我从源代码中获得了这个单行方法的异常(org.drools.impl.adapters.KnowledgeRuntimeAdapter class - 6.1.0.Final version):

public ProcessInstance startProcess(String processId) {
    return new ProcessInstanceAdapter(delegate.startProcess(processId));
}

P.S。代码成功,直到注册WorkItemHandler。完整堆栈跟踪的PSB:

org.eclipse.jdt.internal.junit.runner.RemoteTestRunner at localhost:55158   
    Thread [main] (Suspended)   
        ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286   
        ClassNotFoundException(Exception).<init>(String, Throwable) line: not available 
        ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available  
        ClassNotFoundException.<init>(String) line: not available   
        URLClassLoader$1.run() line: not available  
        URLClassLoader$1.run() line: not available  
        AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]   
        Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available   
        Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
        Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
        Launcher$AppClassLoader.loadClass(String, boolean) line: not available  
        Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available  
        StatefulKnowledgeSessionAdapter(KnowledgeRuntimeAdapter).startProcess(String) line: 149 
        JbpmMigrationTest.testBPMNProcessInstance() line: 151   
        NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
        NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available   
        DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available   
        Method.invoke(Object, Object...) line: not available    
        FrameworkMethod$1.runReflectiveCall() line: 44  
        FrameworkMethod$1(ReflectiveCallable).run() line: 15    
        FrameworkMethod.invokeExplosively(Object, Object...) line: 41   
        InvokeMethod.evaluate() line: 20    
        RunBefores.evaluate() line: 28  
        RunAfters.evaluate() line: 31   
        BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 76  
        BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 50   
        ParentRunner$3.run() line: 193  
        ParentRunner$1.schedule(Runnable) line: 52  
        BlockJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) line: 191  
        ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 42  
        ParentRunner$2.evaluate() line: 184 
        RunBefores.evaluate() line: 28  
        BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 236  
        JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) line: 46   
        TestExecution.run(ITestReference[]) line: 38    
        RemoteTestRunner.runTests(String[], String, TestExecution) line: 467    
        RemoteTestRunner.runTests(TestExecution) line: 683  
        RemoteTestRunner.run() line: 390    
        RemoteTestRunner.main(String[]) line: 197   
    Thread [ReaderThread] (Running) 

以下是我的控制台上单元测试的输出:

Registeredddddddddddddd

org.jbpm.workflow.instance.WorkflowRuntimeException: [SingleNode_Process:1 - myservice:2] -- Could not find work item handler for Service Task
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:168)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:354)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:313)
    at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:66)
    at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:43)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:162)
    at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:226)
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:363)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:187)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:169)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:161)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:156)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:1845)
    at org.drools.impl.adapters.KnowledgeRuntimeAdapter.startProcess(KnowledgeRuntimeAdapter.java:149)
    at org.jbpm.migration.JbpmMigrationTest.testBPMNProcessInstance(JbpmMigrationTest.java:151)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    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)
Caused by: org.drools.core.WorkItemHandlerNotFoundException: Could not find work item handler for Service Task
    at org.drools.core.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:71)
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:133)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:162)
    ... 40 more

2 个答案:

答案 0 :(得分:0)

你能分享整个堆栈的踪迹吗? 没有它,就无法帮助你。您应该确保具有ID SingleNode_Process的进程位于在readKnowledgeBase()方法中创建的KnowledgeBase中。请注意,包含该进程的文件的名称对于启动它并不重要。

HTH

答案 1 :(得分:0)

您似乎正在使用旧的jBPM5 api和jBPM6。您是否有可能以某种方式在类路径中使用旧版本的knowledge-api?

您是否可以尝试使用新的jBPM6 api?就像是: https://github.com/droolsjbpm/droolsjbpm-tools/blob/master/drools-eclipse/org.jbpm.eclipse/src/main/resources/org/jbpm/eclipse/wizard/project/ProcessJUnit-advanced.java.template