<!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="http://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;">
Drools persistence + Websphere 7 + DB2
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/filipon">Philippe Goncalves</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/599266#599266">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 everyone,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm trying to get the persistence of drools flow working in a Websphere 7 + DB2 environment:</p><p>- If I run a simple workflow that runs without any wait state, it's ok, I have no errors. SessionInfo is well persisted.</p><p>- If I run a workflow with a wait state (First launch well persisted), after completing this wait state and before finishing the workflow, I have an error at line 41 of class JPAWorkItemManager:</p><p>((WorkItemImpl) workItem).setId(workItemInfo.getId()); // -> Nullpointer exception because of the the null returned by workItemInfo.getId()</p><p>- If I run a workflow running (For example one with a wait state) and if I try to run another workflow in parallel, I have an error at line 141 of class SingleSessionCommandService:</p><p> ((InternalKnowledgeRuntime) ksession).setId( this.sessionInfo.getId() ); // -> Nullpointer exception because of the the null returned by this.sessionInfo.getId()</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>After invesgating, it seems that I have a problem once the database is locked by a process,  the persists methods from drools don't work anymore for the autogenerated columns of the tables, and then I have problems with tables SessionInfo, WorkItemInfo, etc.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>About the way I instantiate the environment variable for the persistence, I make it singleton:</p><p>...</p><p>    public static Environment getEnvironment() {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        if (environment == null) {</p><p>            EntityManagerFactory emf = Persistence.createEntityManagerFactory("testWorkflow");</p><p>            environment = KnowledgeBaseFactory.newEnvironment();</p><p>            environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);</p><p>        }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        return environment;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Here is my persistence.xml:</p><p><span><persistence xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></p><p><span>    xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span>"</span></p><p><span>    xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span> </span><a class="jive-link-external-small" 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><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence/orm" target="_blank">http://java.sun.com/xml/ns/persistence/orm</a><span> </span><a class="jive-link-external-small" 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><span>"</span></p><p>    version="1.0"></p><p><persistence-unit name="testWorkflow" transaction-type="JTA"></p><p>        <provider>org.hibernate.ejb.HibernatePersistence</provider></p><p>        <jta-data-source>jdbc/testWorkflow</jta-data-source></p><p>        <class>org.drools.persistence.info.SessionInfo</class></p><p>        <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class></p><p>        <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class></p><p>        <class>org.drools.persistence.info.WorkItemInfo</class></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        <properties></p><p>            <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" /></p><p>            <property name="hibernate.max_fetch_depth" value="5" /></p><p>            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" /></p><p>          <property name="hibernate.hbm2ddl.auto" value="update" /></p><p>            <property name="show_sql" value="true" /></p><p>        </properties></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p></persistence-unit></p><p></persistence></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks for your help!</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/599266#599266">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>