<!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;">
    JBPM6 Spring Persistence and Runtime Manager
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/herwix">Alexander Herwix</a> in <i>jBPM Development</i> - <a href="https://community.jboss.org/message/833455#833455">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hey guys,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have been trying to integrate JBPM6 in my Spring-Hibernate based Grails application, but it seems that I'm stuck and maybe you guys here could point me in the right direction.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am trying to get the RuntimeManager working with a local spring transaction scheme. I have tried a lot of stuff but can't seem to find the right approach.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have set up a EntityManagerFactory bean, which loads the persistence-unit org.jbpm.presistence.jpa (with transaction-type "Resource_local") with the org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.</p><p>I have also set up a org.springframework.orm.jpa.JpaTransactionManager bean.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I now try to get a runtimeEngine via the RuntimeEnvironmentBuilder:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefaultInMemory()
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .userGroupCallback(getUserGroupCallback())
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .entityManagerFactory(entityManagerFactory)
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .registerableItemsFactory(<font color="navy"><b>new</b></font> KModuleRegisterableItemsFactory(kcontainer,<font color="navy">''</font>))
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .addEnvironmentEntry(EnvironmentName.TRANSACTION_MANAGER,jbpmTransactionManager)
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .get();
&#160; 
RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
&#160;
RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I get the following error: </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">NamingException occurred when processing request: [GET] /bpm/test/
Cannot create resource instance. Stacktrace follows:
javax.naming.NamingException: Cannot create resource instance
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:116)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at javax.naming.InitialContext.lookup(InitialContext.java:411)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:122)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.persistence.jta.JtaTransactionManager.&lt;init&gt;(JtaTransactionManager.java:69)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.shared.services.impl.JbpmJTATransactionManager.&lt;init&gt;(JbpmJTATransactionManager.java:39)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.runtime.manager.impl.factory.LocalTaskServiceFactory.newTaskService(LocalTaskServiceFactory.java:48)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.getRuntimeEngine(PerProcessInstanceRuntimeManager.java:94)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.init(PerProcessInstanceRuntimeManager.java:258)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.runtime.manager.impl.RuntimeManagerFactoryImpl.newPerProcessInstanceRuntimeManager(RuntimeManagerFactoryImpl.java:103)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.runtime.manager.impl.RuntimeManagerFactoryImpl.newPerProcessInstanceRuntimeManager(RuntimeManagerFactoryImpl.java:94)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at bpm.TestController$$EOFBIT6u.index(TestController.groovy:82)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at java.lang.Thread.run(Thread.java:722)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Looking at the stacktrace I found the the LocalTaskServiceFactory where the documentation says:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>/**</p><p> * Regular &lt;code&gt;TaskServiceFactory&lt;/code&gt; implementation that shall be used for non CDI environments.</p><p> * Creates new &lt;code&gt;TaskService&lt;/code&gt; instance for every call to the factory.</p><p> * &lt;code&gt;TaskService&lt;/code&gt; instance will be equipped with &lt;code&gt;JbpmJTATransactionManager&lt;/code&gt; </p><p> * for transaction management, this is mandatory as it must participate in already active</p><p> * transaction if such exists.</p><p> */</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So it seems it's not possible to use the RuntimeManager without a JTA Transaction Manager? I thought it might be possible to supply the localTransactionManager via the Environment? But I am fishing in the dark.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I am totally off the mark here in what I am doing, I would appreciate any pointer into the recommended way to integrate jbpm6 (and especially the runtime manager) into a spring-hibernate based application. I have looked at kie-spring, but there is little jbpm specific stuff. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Cheers, Alex</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/833455#833455">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>