<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Problem to use JBPM on gwt project
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/sahar_m">sahar mohebi</a> in <i>jBPM Development</i> - <a href="https://community.jboss.org/message/809792#809792">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi friends,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am new on jbpm with many problems!!!</p><p>I want to use jbpm on my gwt project&#160; and mysql.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I get error when I want to create EntityManagerFactory:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>avax.persistence.PersistenceException: <a class="jive-link-external-small" href="" rel="nofollow">PersistenceUnit: org.jbpm.persistence.jpa</a> Unable to build EntityManagerFactory</p><p>&#160;&#160;&#160; at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)</p><p>&#160;&#160;&#160; at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)</p><p>&#160;&#160;&#160; at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)</p><p>&#160;&#160;&#160; at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)</p><p>&#160;&#160;&#160; at com.ayriksoft.desktopapp.server.TaskServiceManager.getInstance(TaskServiceManager.java:319)</p><p>&#160;&#160;&#160; at com.ayriksoft.desktopapp.server.JBPMServiceImpl.setup(JBPMServiceImpl.java:116)</p><p>&#160;&#160;&#160; at com.ayriksoft.desktopapp.server.JBPMServiceImpl.initializeJbpmSession(JBPMServiceImpl.java:51)</p><p>&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p><p>&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p><p>&#160;&#160;&#160; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p><p>&#160;&#160;&#160; at java.lang.reflect.Method.invoke(Method.java:597)</p><p>&#160;&#160;&#160; at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)</p><p>&#160;&#160;&#160; at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)</p><p>&#160;&#160;&#160; at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)</p><p>&#160;&#160;&#160; at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)</p><p>&#160;&#160;&#160; at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)</p><p>&#160;&#160;&#160; at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)</p><p>&#160;&#160;&#160; at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)</p><p>&#160;&#160;&#160; at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)</p><p>&#160;&#160;&#160; at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)</p><p>&#160;&#160;&#160; at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)</p><p>&#160;&#160;&#160; at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)</p><p>&#160;&#160;&#160; at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)</p><p>&#160;&#160;&#160; at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)</p><p>&#160;&#160;&#160; at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)</p><p>&#160;&#160;&#160; at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</p><p>&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:619)</p><p>Caused by: org.hibernate.HibernateException: Could not obtain BTM transaction manager instance</p><p>&#160;&#160;&#160; at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:50)</p><p>&#160;&#160;&#160; at org.hibernate.impl.SessionFactoryImpl.(BitronixTransactionManager.java:62)</p><p>&#160;&#160;&#160; ... 45 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Its my gwt service class:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public class JBPMServiceImpl extends RemoteServiceServlet implements JBPMService {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; protected StatefulKnowledgeSession session;</p><p>&#160;&#160;&#160; private MockWorkItemHandler mockWorkItemHandler;</p><p>&#160;&#160;&#160; Map&amp;lt;Resource, ResourceType&amp;gt; resources;</p><p>&#160;&#160;&#160;&#160; TaskServiceManager tc;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160; public boolean initializeJbpmSession() {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; setup();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session = tc.getSession();//kbase.newStatefulKnowledgeSession();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeRuntimeLoggerFactory.newConsoleLogger(session);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session.addEventListener(new DefaultAgendaEventListener() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; public void afterRuleFlowGroupActivated(org.drools.event.rule.RuleFlowGroupActivatedEvent event) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session.fireAllRules();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session.addEventListener(new DefaultProcessEventListener() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; public void beforeProcessStarted(ProcessStartedEvent event) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session.insert(event.getProcessInstance());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (Exception ex) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ex.printStackTrace();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return false;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return true;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; protected Map&amp;lt;Resource, ResourceType&amp;gt; getResources() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (resources == null) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resources = new HashMap&amp;lt;Resource, ResourceType&amp;gt;();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resources.put(ResourceFactory.newFileResource(System.getProperty("user.home") + "/V1/EmergencyBedRequestV1.bpmn"), ResourceType.BPMN2);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resources.put(ResourceFactory.newFileResource(System.getProperty("user.home") + "/V1/bedAssignmentV1.drl"), ResourceType.DRL);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (Exception ex) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ex.printStackTrace();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return resources;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public void setup() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tc=TaskServiceManager.getInstance();</p><p>//&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tc.startService();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session = tc.getSession();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tc.connect();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(session, "testlog", 1000);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CommandBasedWSHumanTaskHandler taskHandler = new CommandBasedWSHumanTaskHandler(session);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session.getWorkItemManager().registerWorkItemHandler("Human Task", taskHandler);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; session.getWorkItemManager().registerWorkItemHandler("Notification System", taskHandler);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskHandler.connect();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (Exception ex) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Logger.getLogger(JBPMServiceImpl.class.getName()).log(Level.SEVERE, null, ex);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ex.printStackTrace();</p><p>&#160;&#160;&#160;&#160;&#160; throw new RuntimeException("error while creating session", ex);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and Its my TaskServiceManager.java:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public class TaskServiceManager {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; private static String ipAddress = "127.0.0.1";</p><p>&#160;&#160;&#160; //private static int port = 5445;</p><p>&#160;&#160;&#160; private static int port = 9123;</p><p>&#160;&#160;&#160; private static TaskClient client;</p><p>&#160;&#160;&#160; private static Map&lt;String, List&lt;String&gt;&gt; groupListMap = new HashMap();</p><p>&#160;&#160;&#160; private static StatefulKnowledgeSession ksession;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>static TaskServiceManager instance = null;</p><p>&#160;&#160;&#160; static Thread thread;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; private TaskServiceManager() {</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public static TaskServiceManager getInstance() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (instance == null) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; instance = new TaskServiceManager();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MinaTaskServer server = new MinaTaskServer(taskService);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Thread thread = new Thread(server);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; thread.start();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return instance;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public void setConnection(String ipAddress, int port) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ipAddress = ipAddress;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; port = port;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public void connect() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (client == null) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; client = new TaskClient(new MinaTaskClientConnector("client 1",</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; new&#160; MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; client.connect("127.0.0.1", 9123);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; boolean connected = client.connect(ipAddress, port);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!connected) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new IllegalArgumentException(</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; "Could not connect task client");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; public KnowledgeBase readKnowledgeBase(Map&lt;Resource, ResourceType&gt; resources)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throws Exception {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (Map.Entry&lt;Resource, ResourceType&gt; entry : this.getResources().entrySet()) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; kbuilder.add(entry.getKey(), entry.getValue());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (kbuilder.hasErrors()) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeBuilderErrors errors = kbuilder.getErrors();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (KnowledgeBuilderError error : errors) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("&gt;&gt;&gt; Error:" + error.getMessage());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new IllegalStateException("&gt;&gt;&gt; Knowledge couldn't be parsed! ");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return kbase;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public StatefulKnowledgeSession getSession()</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throws Exception {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (ksession == null) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ksession = createSession();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return ksession;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public StatefulKnowledgeSession createSession()</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throws Exception {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.print("ok1");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeBase kbase = readKnowledgeBase(getResources());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.print("ok2");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.print("ok3");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Environment env = KnowledgeBaseFactory.newEnvironment();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; env.set("drools.persistence.jpa.EntityManagerFactory", emf);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; env.set("drools.transaction.TransactionManager", TransactionManagerServices.getTransactionManager());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; env.set("drools.Globals", new MapGlobalResolver());</p><p>//</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Properties properties = new Properties();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; properties.put("drools.processInstanceManagerFactory", "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; properties.put("drools.processSignalManagerFactory", "org.jbpm.persistence.processinstance.JPASignalManagerFactory");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return JPAKnowledgeService.newStatefulKnowledgeSession(kbase , config, env);</p><p>&#160;&#160;&#160; }</p><p>&#160;&#160;&#160; static Map&lt;Resource, ResourceType&gt; resources;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; static Map&lt;Resource, ResourceType&gt; getResources() {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (resources == null) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resources = new HashMap&lt;Resource, ResourceType&gt;();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resources.put(ResourceFactory.newFileResource(System.getProperty("user.home") + "/V1/EmergencyBedRequestV1.bpmn"), ResourceType.BPMN2);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resources.put(ResourceFactory.newFileResource(System.getProperty("user.home") + "/V1/bedAssignmentV1.drl"), ResourceType.DRL);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (Exception ex) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ex.printStackTrace();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return resources;</p><p>&#160;&#160;&#160; }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and its my persistence.xml fil in META_INF:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/809792#809792">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2035">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>