[jboss-jira] [JBoss JIRA] Commented: (JBPM-457) Parent process deployment does not link process-state with subprocess definition
Tyler Mendenhall (JIRA)
jira-events at lists.jboss.org
Mon Jul 9 15:44:53 EDT 2007
[ http://jira.jboss.com/jira/browse/JBPM-457?page=comments#action_12368281 ]
Tyler Mendenhall commented on JBPM-457:
---------------------------------------
This is still an issue in jbpm-jpdl-3.2.1 and causes the same null pointer issue when deploying a process definition that references a subflow in the jbpm console.
I have implemented similar code to resolve the problem in a unit test.
I have a deploy process method:
protected void deployProcess() {
this.dbPersistenceServiceFactory.createSchema();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
String processDef = this.getProcessDefinitionLocation();
if (processDef==null) throw new IllegalArgumentException("unspecified process name");
ProcessDefinition processDefinition =
ProcessDefinition.parseXmlResource(processDef);
jbpmContext.deployProcessDefinition(processDefinition);
this.deploySubProcesses(processDefinition);
} finally {
jbpmContext.close();
}
}
private void deploySubProcesses(ProcessDefinition superProcessDef){
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try{
// for each subprocess defined in the map there will be a node definition in the key
// and the process definition xml location in the value
Map subProcessMap = this.getSubProcessMap();
for (Iterator iter = subProcessMap.keySet().iterator(); iter.hasNext();) {
String nodeName = (String) iter.next();
String definitionLocation = (String)subProcessMap.get(nodeName);
if (definitionLocation==null){
throw new IllegalArgumentException("Node:"+nodeName+" is missing the processdefinition.xml location");
}
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(definitionLocation);
jbpmContext.deployProcessDefinition(processDefinition);
ProcessState node = (ProcessState)superProcessDef.getNode(nodeName);
if (node!=null){
node.setSubProcessDefinition(processDefinition);
} else {
String superName = superProcessDef.getName();
throw new IllegalArgumentException("Node:"+nodeName+" does not exist in "+superName);
}
}
} finally {
jbpmContext.close();
}
}
However it requires the user to set up the association between process nodes in the parent process definition with individual sub classes.
Hopefully this will help out a bit.
Thanks,
Tyler
> Parent process deployment does not link process-state with subprocess definition
> --------------------------------------------------------------------------------
>
> Key: JBPM-457
> URL: http://jira.jboss.com/jira/browse/JBPM-457
> Project: JBoss jBPM
> Issue Type: Bug
> Components: Core Engine
> Reporter: Eduardo Jimenez
> Assigned To: Tom Baeyens
>
> From the ProcessState code:
> Code:
> if (jbpmSession != null) {
>
> // now, we must be able to find the sub-process
> if (subProcessName != null) {
>
> // if the name and the version are specified
> if (subProcessVersion != null) {
>
> try {
> int version = Integer.parseInt(subProcessVersion);
> // select that exact process definition as the subprocess definition
> subProcessDefinition = jbpmSession.getGraphSession().findProcessDefinition(subProcessNam
> e, version);
> } catch (NumberFormatException e) {
> jpdlReader.addWarning("version in process-state was not a number: " + processStateElement.asXML());
> }
>
> } else { // if only the name is specified
> // select the latest version of that process as the subprocess
> // definition
> subProcessDefinition = jbpmSession.getGraphSession().findLatestProcessDefinition(subProces
> sName);
> }
> } else {
> jpdlReader.addWarning("no sub-process name specified in process-state " + processStateElement.asXML());
> }
> }
>
> if there is no session open, it simply won't look for the parent process.
> Now, from the ProcessArchiveDeployer:
> Code:
> public static void deployZipInputStream(ZipInputStream zipInputStream, JbpmSessionFactory jbpmSessio
> nFactory) {
> ProcessDefinition processDefinition = ProcessDefinition.parseParZipInputStream(zipInputStream);
> deployProcessDefinition(processDefinition, jbpmSessionFactory);
> }
>
> It reads the process definition first, then calls deploy, which opens the first jbpmSession!!!. The session must be open first before attempting to deploy!.
> Now, you might say, use the ant task, but the bug is still there:
> Code:
> private void deploy(File file, JbpmSessionFactory jbpmSessionFactory) throws IOException, FileNotFou
> ndException {
> ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(file));
> ProcessArchiveDeployer.deployZipInputStream(zipInputStream,jbpmSessionFactory);
> }
>
> See, the ant task doens't open a jbpmSession either, so its up to ProcessArchiveDeployer.deployZipInputStream() to do it, which is the same method I'm having an issue with.
> Examining ProcessArchiveDeployer, every way of deploying a process would have the same problem.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list