<!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;">
Re: Question to process instance migration
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/kmwen">km wen</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/570852#570852">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>thanks, michael,</p><p>it works, if i deploy new process definition from the same .xml file with different version as following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>ProcessDefinition pd1 = deployProcessDefinitionFromClasspath("org/jbpm/testMigration/a.jpdl.xml");  <br/>  ProcessInstance pi1 = startAndSignal(pd1, "aa");<br/>  ProcessInstance pi2 = startAndSignal(pd1,"b");<br/>  ProcessInstance pi3 = startAndSignal(pd1,"c");<br/>  <br/>  assertTrue(pi3.isActive("c"));<br/>  <br/>  // here get new process definition<br/>  ProcessDefinition pd2 = deployProcessDefinitionFromClasspath("org/jbpm/testMigration/a.jpdl.xml");<br/>  assertEquals(pd2.getId(),"a-2");<br/>  pi3 = executionService.findProcessInstanceById(pi3.getId());<br/>  assertEquals(pd2.getId(),pi3.getProcessDefinitionId());<br/>  <br/>  // here the instances of the previously deployed process definition <br/>  //that are waiting in node "c" will be placed in the node "b". <br/>  assertTrue(pi3.isActive("b"));</p><p>__________________________________________________________________________________________</p><p> I have wrote following code, but it's failed. I want to get the new definition from another process .xml file.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  ProcessDefinition pd1 = deployProcessDefinitionFromClasspath("org/jbpm/testMigration/a.jpdl.xml");  <br/>  ProcessInstance pi1 = startAndSignal(pd1, "aa");<br/>  ProcessInstance pi2 = startAndSignal(pd1,"b");<br/>  final ProcessInstance pi3 = startAndSignal(pd1,"c");<br/>  <br/>  assertTrue(pi3.isActive("c"));<br/>  <br/>  // here get new process definition<br/>  final ProcessDefinition pd2 = deployProcessDefinitionFromClasspath("org/jbpm/testMigration/a1.jpdl.xml");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>new DefaultMigrationHandler().migrateInstance(pd2, pi3, new MigrationDescriptor());</p><p>  <br/>  processEngine.execute(new Command() {<br/>           <br/>   public Object execute(Environment env) {<br/>                new DefaultMigrationHandler().migrateInstance(pd2,<br/>                    pi3, new MigrationDescriptor());<br/>                env.get(Session.class).update(pi3);<br/>                return null;<br/>            }</p><p>  });<br/>  assertTrue(pi3.isActive("b"));<br/>  }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>following is process definition .xml file:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><?xml version="1.0" encoding="UTF-8"?></p><p><process name="a" xmlns="<a class="jive-link-external-small" href="http://jbpm.org/4.4/jpdl">http://jbpm.org/4.4/jpdl</a>"><br/>   <start g="33,107,48,48" name="s"><br/>      <transition to="aa"/><br/>   </start><br/>   <task g="138,107,92,52" name="aa"><br/>      <transition to="b"/><br/>   </task><br/>   <task g="274,108,92,52" name="b"><br/>      <transition to="c"/><br/>   </task><br/>   <task g="407,107,92,52" name="c"><br/>      <transition to="e"/><br/>   </task><br/>   <end g="549,109,48,48" name="e"/><br/>  <migrate-instances><br/>      <activity-mapping old-name="c" new-name="b"/><br/>     </migrate-instances><br/></process></p><p>________________________________-</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><?xml version="1.0" encoding="UTF-8"?></p><p><process name="a1" xmlns="<a class="jive-link-external-small" href="http://jbpm.org/4.4/jpdl">http://jbpm.org/4.4/jpdl</a>">     <br/> <start g="11,99,48,48" name="s">      <br/>  <transition to="aa"/>   <br/>   </start>      <br/>   <state g="106,94,110,52" name="aa">      <br/>   <transition to="x"/>    <br/>   </state>      <br/>   <state g="290,96,110,52" name="x">     <br/>    <transition to="e"/>    <br/>    </state>     <br/>     <end g="499,99,48,48" name="e"/><br/>     <br/> </process></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/570852#570852">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>