在Eclipse中运行jbmp示例时遇到问题

时间:2019-04-02 00:29:19

标签: database eclipse jbpm

有人帮助我解决我的问题吗?当我尝试在Eclipse中运行jbpm示例时。这是代码:

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();
    ksession.startProcess("com.sample.bpmn.hello");

    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");
}

}

然后,这是控制台窗口中的错误:

Exception in thread "main" java.lang.IllegalArgumentException: Driver class name cannot be empty.
at org.kie.test.util.db.internal.DatabaseProvider.fromDriverClassName(DatabaseProvider.java:32)
at org.kie.test.util.db.DataSourceFactory.setupPoolingDataSource(DataSourceFactory.java:57)
at org.kie.test.util.db.DataSourceFactory.setupPoolingDataSource(DataSourceFactory.java:42)
at org.jbpm.test.JBPMHelper.setupDataSource(JBPMHelper.java:103)
at com.sample.ProcessMain.createRuntimeManager(ProcessMain.java:34)
at com.sample.ProcessMain.main(ProcessMain.java:23)

1 个答案:

答案 0 :(得分:0)

  1. jBPMHelper不再设置H2的默认值,-https://github.com/kiegroup/drools/commit/34293e9675ae4f36f2a3a9e633305bbcc8260d19
  2. 我们需要使用-PersistenceUtil.setupPoolingDataSource();而是JBPMHelper.setupDataSource();
  3. 还要在resources文件夹中包含datasource.properties文件。

datasource.properties-> https://github.com/kiegroup/jbpm/blob/master/jbpm-examples/src/main/resources/datasource.properties