问题描述
我试图让我的jBPM项目持久。因此,我使用了这个。
起初,我导入了所有需要的附加罐子(根据网站)。
我还添加了 mysql-connector-java-5.1.20-bin.jar
,因为我想将mysql用作持久存储。
之后,我将有状态代码添加到我的项目中:
pre $知识库kbase = readKnowledgeBase名称);
StatefulKnowledgeSession ksession = null;
JBPMHelper.startH2Server();
JBPMHelper.setupDataSource();
if(ProcessManager.sessionId == -1){
ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);
ProcessManager.sessionId = ksession.getId();
}
else {
ksession = JBPMHelper.loadStatefulKnowledgeSession(
kbase,
ProcessManager.sessionId);
}
然后我添加到 resources / META-INF
文件 jBPM.properties
:
如果我现在运行该项目,总是会出现以下异常(位于 ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);
):
我为我的问题找到了解决方案。通常 JBPMHelper
直接从:
public静态属性getProperties(){
属性properties = new Properties();
尝试{
属性
.load(JBPMHelper.class.getResourceAsStream(/ jBPM.properties));
} catch(Throwable t){
//不做任何事,使用默认值
}
返回属性;
}
我替换了加载机制,现在它正在加载 jBPM.properties
正确:
public static Properties getProperties(){
Properties properties = new Properties();
尝试{
InputStream输入
= new FileInputStream(./ resources / META-INF / jBPM.properties);
properties.load(input);
System.out.println(RPOP+ properties.toString());
} catch(Throwable t){
//不做任何事,使用默认值
}
返回属性;
$ / code>
(我的答案改编自BartoszKP - 谢谢)
I am trying to make my jBPM Project persistent. Therefore I used the this tutorial.At first I imported all the additional jars needed (according to the website).I also added mysql-connector-java-5.1.20-bin.jar
because I want to use mysql as persistent storage.
After that I added the "stateful" code to my project:
KnowledgeBase kbase = readKnowledgeBase(name);
StatefulKnowledgeSession ksession = null;
JBPMHelper.startH2Server();
JBPMHelper.setupDataSource();
if(ProcessManager.sessionId == -1){
ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);
ProcessManager.sessionId = ksession.getId();
}
else {
ksession = JBPMHelper.loadStatefulKnowledgeSession(
kbase,
ProcessManager.sessionId);
}
Then I added to resources/META-INF
the file jBPM.properties
:
If I now run the project there is always the following exception (on ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);
):
I found a solution for my Problem. Normally the JBPMHelper
loads the jBPM directly from the jar:
public static Properties getProperties() {
Properties properties = new Properties();
try {
properties
.load(JBPMHelper.class.getResourceAsStream("/jBPM.properties"));
} catch (Throwable t) {
// do nothing, use defaults
}
return properties;
}
I replaced the loading Mechanism and now it is loading the jBPM.properties
correctly:
public static Properties getProperties() {
Properties properties = new Properties();
try {
InputStream input
= new FileInputStream("./resources/META-INF/jBPM.properties");
properties.load(input);
System.out.println("RPOP"+properties.toString());
} catch (Throwable t) {
// do nothing, use defaults
}
return properties;
}
(My answer adapted from BartoszKP - thanks)
这篇关于jBPM持久性:无法构建EntityManagerFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!