<!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;">
    jBPM5 Database Exception
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/pushpak1981">pushpak1981</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/732727#732727">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,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am trying to start multiple processes parallely using multiple threads (Oracle Database) I am facing the following error:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">20:48:37,321 INFO&#160; [stdout] (Thread-103) Thread StartedThread-103
20:48:37,325 INFO&#160; [stdout] (Thread-104) Thread StartedThread-104
&#160;
20:48:37,328 INFO&#160; [stdout] (Thread-103) Hibernate: select hibernate_sequence.nextval from dual
20:48:37,331 INFO&#160; [stdout] (Thread-104) Hibernate: select hibernate_sequence.nextval from dual
20:48:37,334 INFO&#160; [stdout] (Thread-103) Hibernate: select hibernate_sequence.nextval from dual
20:48:37,335 WARN&#160; [org.hibernate.util.JDBCExceptionReporter] (Thread-104) SQL Error: 0, SQLState: <font color="navy"><b>null</b></font>
20:48:37,342 ERROR [org.hibernate.util.JDBCExceptionReporter] (Thread-104) Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@900b93
20:48:37,339 INFO&#160; [stdout] (Thread-103) Hibernate: select hibernate_sequence.nextval from dual
20:48:37,346 ERROR [org.drools.persistence.SingleSessionCommandService] (Thread-104) Could not commit session: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not get next sequence value
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) [hibernate-entitymanager-3.4.0.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226) [hibernate-entitymanager-3.4.0.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jbpm.persistence.JpaProcessPersistenceContext.persist(JpaProcessPersistenceContext.java:22) [jbpm-persistence-jpa-5.2.0.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:43) [jbpm-persistence-jpa-5.2.0.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:36) [jbpm-flow-5.2.0.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:182) [jbpm-flow-5.2.0.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:154) [jbpm-flow-5.2.0.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:135) [jbpm-flow-5.2.0.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1079) [drools-core-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:306) [drools-core-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:119) [drools-core-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:38) [drools-core-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:345) [drools-persistence-jpa-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.drools.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:42) [drools-core-5.3.1.Final.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.l1id.UnitTest.AsynchronousInterceptor.access$0(AsynchronousInterceptor.java:1) [classes:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.l1id.UnitTest.AsynchronousInterceptor$1.run(AsynchronousInterceptor.java:15) [classes:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:619) [:1.6.0_03]
Caused by: org.hibernate.exception.GenericJDBCException: could not get next sequence value
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:119) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49) [hibernate-entitymanager-3.4.0.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:646) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:620) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:624) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220) [hibernate-entitymanager-3.4.0.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ... 16 more
Caused by: java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@900b93
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.jca.adapters.jdbc.WrappedConnection.lock(WrappedConnection.java:151)
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:391)
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.jdbc.AbstractBatcher.prepareSelectStatement(AbstractBatcher.java:145) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96) [hibernate-core-3.3.2.GA.jar:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ... 25 more
&#160;
20:48:37,352 INFO&#160; [stdout] (Thread-103) Hibernate: select hibernate_sequence.nextval from dual
20:48:37,449 ERROR [stderr] (Thread-104) Exception in thread <font color="red">"Thread-104"</font> javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not get next sequence value
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>From the logs we observed that only one process is completed and other thread goes into an error state. I am using CommandBasedStatefulKnowledgeSession.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Has any one faced similar issue.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks</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/732727#732727">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://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>