我收到以下错误:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Nov 09, 2014 4:11:06 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
Nov 09, 2014 4:11:06 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.12.Final}
Nov 09, 2014 4:11:06 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Nov 09, 2014 4:11:06 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Nov 09, 2014 4:11:06 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/JBPMorm.xml
Nov 09, 2014 4:11:06 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/Taskorm.xml
Nov 09, 2014 4:11:06 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/TaskAuditorm.xml
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at org.jbpm.runtime.manager.impl.jpa.EntityManagerFactoryManager.getOrCreate(EntityManagerFactoryManager.java:33)
at org.jbpm.runtime.manager.impl.DefaultRuntimeEnvironment.init(DefaultRuntimeEnvironment.java:73)
at org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder.get(RuntimeEnvironmentBuilder.java:400)
at org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder.get(RuntimeEnvironmentBuilder.java:74)
at main.java.ProcessTest.main(ProcessTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
... 5 more
Caused by: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [jdbc/jbpm-ds]
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 19 more
Caused by: javax.naming.NameNotFoundException: unable to find a bound object at name 'jdbc/jbpm-ds'
at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)
at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:67)
at javax.naming.InitialContext.lookup(InitialContext.java:421)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
... 32 more
这是我使用的代码:
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.manager.*;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.runtime.manager.context.EmptyContext;
public class ProcessTest {
public static void main(String[] args) {
// KieHelper kieHelper = new KieHelper();
// kieHelper.addResource(ResourceFactory.newClassPathResource("main/resource/Hello.bpmn"));
// KieBase kieBase = kieHelper.build();
// KieSession kieSession = kieBase.newKieSession();
// ProcessInstance processInstance = kieSession.startProcess("com.sample.hello");
// System.out.println("Process completed ? " + (processInstance.getState() == ProcessInstance.STATE_COMPLETED));
RuntimeEnvironment runtimeEnvironment = RuntimeEnvironmentBuilder.Factory.get()
.newDefaultInMemoryBuilder()
.addAsset(ResourceFactory.newClassPathResource("main/resource/Hello.bpmn"), ResourceType.BPMN2)
.get();
RuntimeManager runtimeManager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(runtimeEnvironment);
RuntimeEngine runtimeEngine = runtimeManager.getRuntimeEngine(EmptyContext.get());
KieSession kieSession = runtimeEngine.getKieSession();
ProcessInstance processInstance = kieSession.startProcess("com.sample.hello");
System.out.println("Process completed ? " + (processInstance.getState() == ProcessInstance.STATE_COMPLETED));
runtimeManager.disposeRuntimeEngine(runtimeEngine);
runtimeManager.close();
}
}
和Hello.bpmn
:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.jboss.org/drools" xmlns="http://www.jboss.org/drools" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" id="Definition" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
<bpmn2:process id="com.sample.hello" tns:version="1" tns:packageName="defaultPackage" tns:adHoc="false" name="Hello Process" isExecutable="true" processType="Private">
<bpmn2:startEvent id="_1" name="Start">
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:sequenceFlow id="SequenceFlow_3" tns:priority="1" name="" sourceRef="_1" targetRef="ScriptTask_1"/>
<bpmn2:scriptTask id="ScriptTask_1" name="Hello" scriptFormat="http://www.java.com/java">
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
<bpmn2:script>System.out.println("Hello");</bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_4" tns:priority="1" name="" sourceRef="ScriptTask_1" targetRef="EndEvent_1"/>
<bpmn2:endEvent id="EndEvent_1" name="End">
<bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
</bpmn2:endEvent>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Hello Process">
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="com.sample.hello">
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="_1">
<dc:Bounds height="36.0" width="36.0" x="45.0" y="45.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_ScriptTask_1" bpmnElement="ScriptTask_1">
<dc:Bounds height="50.0" width="110.0" x="190.0" y="38.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="442.0" y="46.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_ScriptTask_1">
<di:waypoint xsi:type="dc:Point" x="81.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="179.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="179.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="190.0" y="63.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="BPMNShape_ScriptTask_1" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="300.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="422.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="422.0" y="64.0"/>
<di:waypoint xsi:type="dc:Point" x="442.0" y="64.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
进口有问题吗?我做错了吗?
另一个问题, 在jBPM 4中,我们能够轻松地从特定类调用方法,但是如何在jBPM 6中执行此操作?
感谢。