<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hello,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>I
switch from drools 5.0.1 to drools 5.1.0, the problem is resolved, I used the bitronix
transaction manager, I kept </span>transaction-type=&quot;RESOURCE_LOCAL&quot;.
So every things seem to be good, I have no exception.<o:p></o:p></p>

<p class=MsoNormal>But no data is persisted in my database. So I tried to
change de transaction type to JTA but I m getting the exception bellow :<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>SEVERE: an assertion failure occured (this
may indicate a bug in Hibernate, but is more likely due to unsafe use of the
session)</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>org.hibernate.AssertionFailure:
Transaction MARKED_FOR_JOINED after isOpen() call</span><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>AbstractEntityManagerImpl.java:465</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.AbstractEntityManagerImpl.postInit(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>AbstractEntityManagerImpl.java:82</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.EntityManagerImpl.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>EntityManagerImpl.java:61</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>EntityManagerFactoryImpl.java:39</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>EntityManagerFactoryImpl.java:34</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.session.DefaultJpaManager.getApplicationScopedEntityManager(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>DefaultJpaManager.java:37</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>SingleSessionCommandService.java:124</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>Native Method</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
java.lang.reflect.Constructor.newInstance(Unknown Source)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>KnowledgeStoreServiceImpl.java:119</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>KnowledgeStoreServiceImpl.java:57</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>JPAKnowledgeService.java:109</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at com.sample.ProcessTest.main(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>ProcessTest.java:69</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><u><span style='font-size:10.0pt;
font-family:"Courier New";color:navy'>java.lang.IllegalStateException</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>: </span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>java.lang.reflect.InvocationTargetException</span></u><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>KnowledgeStoreServiceImpl.java:133</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>KnowledgeStoreServiceImpl.java:57</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>JPAKnowledgeService.java:109</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at com.sample.ProcessTest.main(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>ProcessTest.java:69</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>Caused by: </span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>java.lang.reflect.InvocationTargetException</span></u><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>Native Method</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at java.lang.reflect.Constructor.newInstance(Unknown
Source)</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>KnowledgeStoreServiceImpl.java:119</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      ... 3 more</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>Caused by: </span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>java.lang.RuntimeException</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>: Could not commit
session</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>SingleSessionCommandService.java:135</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      ... 8 more</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>Caused by: org.hibernate.AssertionFailure:
Transaction MARKED_FOR_JOINED after isOpen() call</span><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>AbstractEntityManagerImpl.java:465</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.AbstractEntityManagerImpl.postInit(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>AbstractEntityManagerImpl.java:82</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.EntityManagerImpl.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>EntityManagerImpl.java:61</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>EntityManagerFactoryImpl.java:39</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>EntityManagerFactoryImpl.java:34</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.session.DefaultJpaManager.getApplicationScopedEntityManager(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>DefaultJpaManager.java:37</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>      at
org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>SingleSessionCommandService.java:124</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:red'>      ... 8 more<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I tried to add the objects you mentioned, I added only 3, I didn’t
add  <o:p></o:p></span></p>

<p class=MsoNormal>env.set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY,
this.txSvc.getTransactionSynchronizationRegistry());<o:p></o:p></p>

<p class=MsoNormal>because <o:p></o:p></p>

<p class=MsoNormal>new InitialContext().lookup( &quot;java:comp/env/TransactionSynchronizationRegistry&quot;
); <o:p></o:p></p>

<p class=MsoNormal>Return null even I add <o:p></o:p></p>

<p class=MsoNormal>javax.transaction.TransactionSynchronizationRegistry  = bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory<o:p></o:p></p>

<p class=MsoNormal>in my jndi.properties file<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>here is my code<o:p></o:p></p>

<p class=MsoNormal style='margin-left:1.0in;text-autospace:none'><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>    UserTransaction
ut = (UserTransaction) </span><b><span style='font-size:10.0pt;font-family:
"Courier New";color:#7F0055'>new</span></b><span style='font-size:10.0pt;
font-family:"Courier New";color:black'> InitialContext().lookup( </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;java:comp/UserTransaction&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> );</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:#3F7F5F'>                // create the entity
manager factory and register it in the environment</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                EntityManagerFactory emf
=  Persistence.<i>createEntityManagerFactory</i>( </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;org.drools.persistence.jpa&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> );</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                Environment env =
KnowledgeBaseFactory.<i>newEnvironment</i>();</span><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                env.set( EnvironmentName.</span><i><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>ENTITY_MANAGER_FACTORY</span></i><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>, emf );</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                env.set(EnvironmentName.</span><i><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>TRANSACTION_MANAGER</span></i><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,
TransactionManagerServices.<i>getTransactionManager</i>()); </span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                env.set(EnvironmentName.</span><i><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>GLOBALS</span></i><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
MapGlobalResolver()); </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>            </span><span lang=FR style='font-size:10.0pt;
font-family:"Courier New";color:black'>    env.set(EnvironmentName.</span><i><span
lang=FR style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>TRANSACTION</span></i><span
lang=FR style='font-size:10.0pt;font-family:"Courier New";color:black'>, ut);</span><span
lang=FR><o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:3.0in;text-indent:-120.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>//TransactionSynchronizationRegistryHelper
<u>tsr</u> = (TransactionSynchronizationRegistryHelper) new InitialContext().lookup(
&quot;java:comp/<u>env</u>/TransactionSynchronizationRegistry&quot; );</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:#3F7F5F'>                // <u>env</u>.set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY,
<u>tsr</u> ); </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>// create a
new knowledge session that uses JPA to store the runtime state</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                StatefulKnowledgeSession
ksession = JPAKnowledgeService.<i>newStatefulKnowledgeSession</i>( kbase, </span><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>null</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>, env );</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>// start the
transaction</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                      ut.begin();</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>// invoke
methods on your method here</span><span style='font-size:10.0pt;font-family:
"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                ProcessInstance process
= ksession.startProcess( </span><span style='font-size:10.0pt;font-family:"Courier New";
color:#2A00FF'>&quot;com.sample.ruleflow&quot;</span><span style='font-size:
10.0pt;font-family:"Courier New";color:black'> );</span><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                ksession.signalEvent(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;Test&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;Test&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,
process.getId());</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                ut.commit();</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                ut.begin();</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                ksession.fireAllRules();</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>// commit the
transaction</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>                ut.commit();</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>                ksession.dispose();</span><span lang=FR><o:p></o:p></span></p>

<p class=MsoNormal><span lang=FR><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=FR style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>any idea&nbsp;?<o:p></o:p></span></p>

<p class=MsoNormal><span lang=FR style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=FR style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thanks<o:p></o:p></span></p>

<p class=MsoNormal><span lang=FR style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=FR style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Regards,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=FR style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal style='margin-left:.5in'><b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Rui Tang<br>
<b>Sent:</b> Friday,May 13,2011 3:58 AM<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] Drools Human Task Service Persistence<o:p></o:p></span></p>

</div>

<p class=MsoNormal style='margin-left:.5in'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>Drools Persistence JPA module must use JTA instead of
local transaction.<br>
<br>
&lt;persistence-unit name=&quot;org.drools.persistence.jpa&quot;
transaction-type=&quot;RESOURCE_LOCAL&quot;&gt;<br>
<br>
should change to <br>
<br>
&lt;persistence-unit name=&quot;default&quot;
transaction-type=&quot;JTA&quot;&gt;<br>
<br>
and<br>
<br>
env.set( EnvironmentName.TRANSACTION_MANAGER, XXXXXXXXXXX );<br>
<br>
your transaction manager should be get from JNDI like <br>
<br>
UserTransaction utx = (UserTransaction)
ctx.lookup(&quot;java:comp/UserTransaction&quot;);<br>
<br>
Your JBoss transaction manager component should register the UserTransaction
into that JNDO name. (In some JTA implementations the UserTransaction and
TransactionManager have the same interfaces). And to make Drools Persistence
JPA works, you should put 4 or 5 objects into env, they are: <br>
<br>
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY,
this.defaultPersistenceSvc.getSessionFactory());<br>
env.set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER,
this.defaultPersistenceSvc.getCurrentSession()); // If you don't handle the
EntityManager your self, you can omit this line.<br>
env.set(EnvironmentName.TRANSACTION_MANAGER,
this.txSvc.getTransactionManager()); // java:comp/env/TransactionManager<br>
env.set(EnvironmentName.TRANSACTION, this.txSvc.getTransaction()); //
java:comp/UserTransaction<br>
env.set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY,
this.txSvc.getTransactionSynchronizationRegistry()); //
java:comp/env/TransactionSynchronizationRegistry<br>
<br>
all the methods called from txSvc fetch objects from according JNDI. In my
application all these JNDI objects are config-ed via Tomcat like this (in
META-INF/context.xml):<br>
<br>
&nbsp;&nbsp;&nbsp; &lt;Resource name=&quot;jdbc/defaultDS&quot;
auth=&quot;Container&quot; type=&quot;javax.sql.XADataSource&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
factory=&quot;bitronix.tm.resource.ResourceObjectFactory&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
uniqueName=&quot;jdbc/defaultDS&quot; /&gt;<br>
<br>
&nbsp;&nbsp;&nbsp; &lt;Resource name=&quot;jdbc/droolsTaskDS&quot;
auth=&quot;Container&quot; type=&quot;javax.sql.XADataSource&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
factory=&quot;bitronix.tm.resource.ResourceObjectFactory&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
uniqueName=&quot;jdbc/droolsTaskDS&quot; /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &lt;Resource name=&quot;TransactionManager&quot;
auth=&quot;Container&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type=&quot;javax.transaction.TransactionManager&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
factory=&quot;bitronix.tm.BitronixTransactionManagerObjectFactory&quot; /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &lt;Resource
name=&quot;TransactionSynchronizationRegistry&quot; auth=&quot;Container&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
type=&quot;javax.transaction.TransactionSynchronizationRegistry&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; factory=&quot;bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory&quot;
/&gt;<br>
<br>
&nbsp;&nbsp;&nbsp; &lt;Resource name=&quot;UserTransaction&quot;
auth=&quot;Container&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
type=&quot;javax.transaction.UserTransaction&quot; /&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;Transaction
factory=&quot;bitronix.tm.BitronixUserTransactionObjectFactory&quot; /&gt;<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'>On Thu, May 12, 2011 at 11:25 PM,
loumimi &lt;<a href="mailto:moundir.jamal-ext@sgcib.com">moundir.jamal-ext@sgcib.com</a>&gt;
wrote:<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Hello Ram,<br>
<br>
I'm running a simple J2SE application (a hello world), I'm trying to persist<br>
a simple drools workflow into Oracle DB.<br>
Here's my configuration :<br>
Oracle 10.2.0.4.0<br>
drools-decisiontables-5.0.1.jar<br>
hibernate-core-3.3.0.SP1.jar<br>
...<br>
<br>
persistence.xml :<br>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;
standalone=&quot;yes&quot;?&gt;<br>
<br>
&lt;persistence<br>
&nbsp;version=&quot;1.0&quot;<br>
&nbsp;xsi:schemaLocation=<br>
&nbsp; &nbsp;&quot;<a href="http://java.sun.com/xml/ns/persistence"
target="_blank">http://java.sun.com/xml/ns/persistence</a><br>
&nbsp; &nbsp; <a
href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
target="_blank">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd</a><br>
&nbsp; &nbsp; <a href="http://java.sun.com/xml/ns/persistence/orm"
target="_blank">http://java.sun.com/xml/ns/persistence/orm</a><br>
&nbsp; &nbsp; <a href="http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
target="_blank">http://java.sun.com/xml/ns/persistence/orm_1_0.xsd</a>&quot;<br>
&nbsp;xmlns:orm=&quot;<a href="http://java.sun.com/xml/ns/persistence/orm"
target="_blank">http://java.sun.com/xml/ns/persistence/orm</a>&quot;<br>
&nbsp;xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance"
target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>
&nbsp;xmlns=&quot;<a href="http://java.sun.com/xml/ns/persistence"
target="_blank">http://java.sun.com/xml/ns/persistence</a>&quot;&gt;<br>
<br>
<br>
&nbsp;&lt;persistence-unit name=&quot;org.drools.persistence.jpa&quot;<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'>transaction-type=&quot;RESOURCE_LOCAL&quot;&gt;<br>
&nbsp; &nbsp;&lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp;
&nbsp;&lt;class&gt;org.drools.persistence.session.SessionInfo&lt;/class&gt;<br>
<br>
&lt;class&gt;org.drools.persistence.processinstance.ProcessInstanceInfo&lt;/class&gt;<br>
<br>
&lt;class&gt;org.drools.persistence.processinstance.ProcessInstanceEventInfo&lt;/class&gt;<br>
&nbsp; &nbsp;&lt;class&gt;org.drools.persistence.processinstance.WorkItemInfo&lt;/class&gt;<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'><br>
&nbsp; &nbsp;&lt;properties&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;property name=&quot;hibernate.dialect&quot;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'>value=&quot;org.hibernate.dialect.Oracle10gDialect&quot;/&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;property
name=&quot;hibernate.connection.driver_class&quot;<br>
value=&quot;oracle.jdbc.OracleDriver&quot;/&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;property name=&quot;hibernate.connection.url&quot;<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>value=&quot;jdbc:oracle:thin:@gfxdevdb01.fr.world.xxxx:1567:CCOD02&quot;/&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;property name=&quot;hibernate.connection.username&quot;
value=&quot;xxxx&quot;/&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;property name=&quot;hibernate.connection.password&quot;
value=&quot;xxxx&quot;/&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;property
name=&quot;hibernate.connection.autocommit&quot; value=&quot;true&quot; /&gt;<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp;&lt;property
name=&quot;hibernate.max_fetch_depth&quot; value=&quot;3&quot;/&gt;<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp;&lt;property
name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;update&quot; /&gt;<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp;&lt;property
name=&quot;hibernate.show_sql&quot; value=&quot;true&quot; /&gt;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp;&lt;property
name=&quot;hibernate.transaction.manager_lookup_class&quot;<br>
value=&quot;org.hibernate.transaction.JBossTransactionManagerLookup&quot; /&gt;<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp;&lt;/properties&gt;<br>
&nbsp;&lt;/persistence-unit&gt;<br>
&lt;/persistence&gt;<br>
<br>
<br>
----<br>
orm.xml :<br>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
&lt;entity-mappings xmlns=&quot;<a
href="http://java.sun.com/xml/ns/persistence/orm" target="_blank">http://java.sun.com/xml/ns/persistence/orm</a>&quot;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns:xsi=&quot;<a
href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>
<br>
xsi:schemaLocation=&quot;<a href="http://java.sun.com/xml/ns/persistence/orm"
target="_blank">http://java.sun.com/xml/ns/persistence/orm</a>
orm_1_0.xsd&quot;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version=&quot;1.0&quot;&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;named-query
name=&quot;ProcessInstancesWaitingForEvent&quot;&gt;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;query&gt;<br>
select<br>
&nbsp; &nbsp;processInstanceInfo.processInstanceId<br>
from<br>
&nbsp; &nbsp;ProcessInstanceInfo processInstanceInfo<br>
where<br>
&nbsp; &nbsp;:type in elements(processInstanceInfo.eventTypes)<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query&gt;<br>
&nbsp; &nbsp; &nbsp;&lt;/named-query&gt;<br>
&lt;/entity-mappings&gt;<br>
<br>
<br>
---<br>
the code :<br>
public static final void main(String[] args) {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try {<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;KnowledgeBuilder kbuilder =<br>
KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;kbuilder.add(ResourceFactory.newClassPathResource(&quot;ruleflow.rf&quot;),<br>
ResourceType.DRF);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;KnowledgeBuilderErrors errors =
kbuilder.getErrors();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (errors.size() &gt; 0) {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for
(KnowledgeBuilderError error: errors) {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;System.err.println(error);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throw new
IllegalArgumentException(&quot;Could not parse<br>
knowledge.&quot;);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;// create the entity manager factory and register it
in the<br>
environment<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EntityManagerFactory emf =
&nbsp;Persistence.createEntityManagerFactory(<br>
&quot;org.drools.persistence.jpa&quot; );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Environment env = KnowledgeBaseFactory.newEnvironment();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
emf );<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp;env.set(
EnvironmentName.TRANSACTION_MANAGER, XXXXXXXXXXX );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// create
a new knowledge session that uses JPA to store the runtime<br>
state<o:p></o:p></p>

<div>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;StatefulKnowledgeSession ksession =<br>
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// invoke methods on your method here<o:p></o:p></p>

<div>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;ksession.startProcess( &quot;com.sample.ruleflow&quot; );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;ksession.fireAllRules();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;ksession.dispose();<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;} catch (Throwable t) {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;t.printStackTrace();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
<br>
I don't know If I miss something<br>
<span style='color:#888888'><br>
--<br>
View this message in context: <a
href="http://drools.46999.n3.nabble.com/Drools-Human-Task-Service-Persistence-tp1868778p2932251.html"
target="_blank">http://drools.46999.n3.nabble.com/Drools-Human-Task-Service-Persistence-tp1868778p2932251.html</a></span><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal style='margin-left:.5in'>Sent from the Drools: User forum
mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></p>

</div>

</div>

</div>

<p class=MsoNormal style='margin-left:.5in'><br>
<br clear=all>
<br>
-- <br>
<span style='font-family:"MS Mincho"'>唐睿</span> <span style='font-family:"MS Mincho"'>研</span><span
style='font-family:SimSun'>发部</span><br>
<span style='font-family:"MS Mincho"'>深圳市中昱达信息技</span><span style='font-family:
SimSun'>术有限责任公司</span><br>
<span style='font-family:SimSun'>电话:</span>0755-26966586-804<br>
<span style='font-family:SimSun'>传真:</span>0755-26966586-802<br>
<span style='font-family:"MS Mincho"'>手机:</span>86-18688827156<br>
<span style='font-family:"MS Mincho"'>网址:</span><a href="http://www.zyeeda.com/"
target="_blank">www.zyeeda.com</a><br>
<span style='font-family:"MS Mincho"'>地址:深圳市</span><span style='font-family:
SimSun'>罗湖区金塘街</span>48<span style='font-family:"MS Mincho"'>号蔡屋</span><span
style='font-family:SimSun'>围丽晶大厦南座</span>1206<span style='font-family:"MS Mincho"'>(</span>518010<span
style='font-family:"MS Mincho"'>)</span><br>
<br>
<span style='font-family:"MS Mincho"'>本</span><span style='font-family:SimSun'>邮件(包括任何附件)含有专供明确的个人和目的使用</span><span
style='font-family:"MS Mincho"'>的机密信息,并受法律保</span><span style='font-family:
SimSun'>护。如果您并非指定收件人,请立即删除此邮件及其附件(如有),并勿使用、披露、复制或分发此邮件或据此采取任何行动。</span><br>
<br>
Copyright © 2011 ZYEEDA CO., LTD. ALL RIGHTS RESERVED <span style='font-family:
"MS Mincho"'>中昱达公司</span> <span style='font-family:"MS Mincho"'>版</span><span
style='font-family:SimSun'>权所</span><span style='font-family:"MS Mincho"'>有</span><o:p></o:p></p>

</div>

<font face="monospace">*************************************************************************<br>
This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information.<br>
Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration.&nbsp;  <br>
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or<br>
falsified.<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ************<br>
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes <br>
par le secret professionnel. <br>
Ce message est etabli a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite.<br>
Tout message electronique est susceptible d'alteration. <br>
La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.<br>
*************************************************************************</font></body>

</html>