2015-05-29 104 views
0

我想創建一個使用jBPM的進程,我使用的是Jboss 7.1服務器,並且我安裝了用於eclipse Kepler的jbpm插件並添加了罐子。現在我創建一個簡單的hello世界項目,但我總是有一個錯誤:jBPM與日食錯誤java.lang.RuntimeException

java.lang.RuntimeException: RuntimeManagerFactory was not initialized, see previous errors 
    at org.kie.api.runtime.manager.RuntimeManagerFactory$Factory.get(RuntimeManagerFact  ory.java:112) 
at org.jbpm.test.JbpmJUnitBaseTestCase.<init> (JbpmJUnitBaseTestCase.java:119) 
    at org.jbpm.test.JbpmJUnitBaseTestCase.<init> (JbpmJUnitBaseTestCase.java:157) 
    at com.sample.ProcessTest.<init>(ProcessTest.java:54) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 

請幫忙嗎?

這是主要的代碼:

import javax.persistence.EntityManagerFactory; 
import javax.persistence.Persistence; 
import org.jbpm.test.JBPMHelper; 
import org.kie.api.KieBase; 
import org.kie.api.KieServices; 
import org.kie.api.runtime.KieContainer; 
import org.kie.api.runtime.KieSession; 
import org.kie.api.runtime.manager.RuntimeEngine; 
import org.kie.api.runtime.manager.RuntimeEnvironmentBuilder; 
import org.kie.api.runtime.manager.RuntimeManager; 
import org.kie.api.runtime.manager.RuntimeManagerFactory; 
import org.kie.api.task.TaskService; 
import org.kie.api.task.model.TaskSummary; 

public class ProcessMain { 

public static void main(String[] args) { 
    KieServices ks = KieServices.Factory.get(); 
    KieContainer kContainer = ks.getKieClasspathContainer(); 
    KieBase kbase = kContainer.getKieBase("kbase"); 

    RuntimeManager manager = createRuntimeManager(kbase); 
    RuntimeEngine engine = manager.getRuntimeEngine(null); 
    KieSession ksession = engine.getKieSession(); 
    TaskService taskService = engine.getTaskService(); 

    ksession.startProcess("com.sample.bpmn.hello"); 

    // let john execute Task 1 
    List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK"); 
    TaskSummary task = list.get(0); 
    System.out.println("John is executing task " + task.getName()); 
    taskService.start(task.getId(), "john"); 
    taskService.complete(task.getId(), "john", null); 

    // let mary execute Task 2 
    list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK"); 
    task = list.get(0); 
    System.out.println("Mary is executing task " + task.getName()); 
    taskService.start(task.getId(), "mary"); 
    taskService.complete(task.getId(), "mary", null); 

    manager.disposeRuntimeEngine(engine); 
    System.exit(0); 
} 

private static RuntimeManager createRuntimeManager(KieBase kbase) { 
    JBPMHelper.startH2Server(); 
    JBPMHelper.setupDataSource(); 
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); 
    RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get() 
     .newDefaultBuilder().entityManagerFactory(emf) 
     .knowledgeBase(kbase); 
    return RuntimeManagerFactory.Factory.get() 
     .newSingletonRuntimeManager(builder.get(), "com.sample:example:1.0"); 
} 

    } 
+0

你能告訴你如何得到'RuntimeManager'或者產生錯誤的完整例子嗎? –

+0

我更新我的問題,並顯示主代碼 – sad

回答

0

我有同樣的問題,我解決它!

如果您在RuntimeEnvironmentBuilder source code獲得的眼睛,你會發現,該方法Factory.get()拋出你得到,如果RuntimeEnvironmentBuilderFactory的一個實例是空的錯誤!

但它是如何構建該實例? 它使用這個類org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder 因此,因爲您在類路徑中沒有此類,所以無法構造該實例並保持爲空。

您可以在jbpm-runtime-manager-6.4.0.Final.jar或您選擇的任何其他jar中找到此類。

希望這會有所幫助!