<!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;">
    persisted stateful sessions and knowledge base changes
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/jordi_alvarez">Jordi Alvarez</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/628586#628586">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p dir="ltr">Hello, I am working for an organization for which we have adopted jBPM as the BPM solution. We are making use also of Drools</p><p><p dir="ltr">Expert, which results in a nice combination.</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">We have stateful sessions persisted in a database in order to record the state of long-time running processes (which are the goal of our</p><p dir="ltr">BPM).</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">In order to make changes to the knowledge-base associated to the stateful sessions that we have, we always redeploy the whole system (ear application + rules + process definitions). This is where we have the problem. Depending on the changes performed to the database, the system is not able to reload the persisted sessions (the change could be for example a change in the condition of a rule). This results in problems and stack traces similar to the following one:</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">[...]</p><p dir="ltr">Caused by: java.lang.RuntimeException: Unable to load session snapshot</p><p dir="ltr">at org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:96)</p><p dir="ltr">at org.drools.persistence.session.SingleSessionCommandService.initKsession(SingleSessionCommandService.java:196)</p><p dir="ltr">at org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(SingleSessionCommandService.java:159)</p><p dir="ltr">... 95 more</p><p dir="ltr">Caused by: java.lang.ClassCastException: org.drools.reteoo.ObjectTypeNode</p><p dir="ltr">at org.drools.marshalling.impl.InputMarshaller.readRightTuple(InputMarshaller.java:401)</p><p dir="ltr">at org.drools.marshalling.impl.InputMarshaller.readRightTuples(InputMarshaller.java:391)</p><p dir="ltr">at org.drools.marshalling.impl.InputMarshaller.readFactHandles(InputMarshaller.java:326)</p><p dir="ltr">at org.drools.marshalling.impl.InputMarshaller.readSession(InputMarshaller.java:205)</p><p dir="ltr">at org.drools.marshalling.impl.DefaultMarshaller.unmarshall(DefaultMarshaller.java:91)</p><p dir="ltr">at org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:91)</p><p dir="ltr">... 97 more</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">According to some posts (which mainly relate to drools expert), if we were using the knowledge agent we could update the already loaded sessions, which would allow to migrate in-memory sessions from the old database to the new database: </p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr"><a class="jive-link-external-small" href="http://drools.46999.n3.nabble.com/Dynamic-updates-of-stateful-sessions-td2834623.html">http://drools.46999.n3.nabble.com/Dynamic-updates-of-stateful-sessions-td2834623.html</a></p><p dir="ltr"><a class="jive-link-external-small" href="http://stackoverflow.com/questions/4368148/is-it-possible-to-add-a-new-rule-to-a-running-drools-session">http://stackoverflow.com/questions/4368148/is-it-possible-to-add-a-new-rule-to-a-running-drools-session</a></p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">Nevertheless, we absolutely need a way to migrate persisted sessions from the old database to the new one. Even in the situation in which we would allow hot modification of the knowledge base, we cannot have all the stateful sessions loaded in memory when this would happen.</p><p dir="ltr">Is there any facility provided by Drools Expert/Flow that allows to perform this operations easily? Is there a way/configuration to</p><p dir="ltr">load/save sessions without the need to store/retrieve the rete-tree (and instead recomputing it), which seems to be the problem for these</p><p dir="ltr">situations.</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">We have already posted this information into drools mailing list; but nobody has answered yet. Any help is appreciated!</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p dir="ltr">Many thanks in advance,</p><p dir="ltr">Jordi Alvarez</p><p dir="ltr" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></p><p><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a></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/628586#628586">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>