David Harris
2013-05-02 16:01:35 UTC
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion
"Drools XML error when passing process variables to work item"
To view the discussion, visit: https://community.jboss.org/message/811284#811284
--------------------------------------------------------------
I've been reading through "Section 7.2.3, Using your new work item in your processes" to see how to pass process variables to a work item. Even though the values of each process variable are getting passed each work item, I'm getting the following XML error in the Eclipse console:
| 1 | 02/05 11:43:16,406[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-id.2: There are multiple occurrences of ID value '_4_Source_IPInput'. |
| 4 | 02/05 11:43:16,409[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-attribute.3: The value '_4_Source_IPInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
| 5 | 02/05 11:43:16,410[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-id.2: There are multiple occurrences of ID value '_4_Start_DateInput'. |
| 5 | 02/05 11:43:16,410[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-attribute.3: The value '_4_Start_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
| 6 | 02/05 11:43:16,411[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-id.2: There are multiple occurrences of ID value '_4_End_DateInput'. |
| 6 | 02/05 11:43:16,411[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-attribute.3: The value '_4_End_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
*parameters passed into work item: 111.111.111.111, 2013 05 02 09:00:00, 2013 04 02 09:00:00*
Note the last line in red shows the values are being passed. Does anyone see anything in the folllowing that would cause the Drools XML error?
**********
public class ProcessMain {
   public static final void main(String[] args) throws Exception {
       // load up the knowledge base
       KnowledgeBase kbase = readKnowledgeBase();
       StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       // start a new process instance
       Map<String,Object> params = new HashMap<String,Object>();
       params.put("processIP", "111.111.111.111");
       params.put("processStartDate", "2013 05 02 09:00:00");
       params.put("processEndDate", "2013 04 02 09:00:00");
       ksession.getWorkItemManager().registerWorkItemHandler("IP Conversations", new IPConversationsWorkItemHandler());
       ksession.startProcess("com.sample.bpmn.hello",params);
   }
   private static KnowledgeBase readKnowledgeBase() throws Exception {
       KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
       kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
       return kbuilder.newKnowledgeBase();
   }
}
***********
The Work Item Handler is:
**********
package com.sample;
import org.drools.runtime.process.WorkItem;
import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
import java.sql.*;
import java.util.*;
public class IPConversationsWorkItemHandler implements WorkItemHandler {
   public void executeWorkItem (WorkItem workItem, WorkItemManager manager) {
       // extract parameters
       String sourceIP = (String) workItem.getParameter("Source_IP");
       String startDate = (String) workItem.getParameter("Start_Date");
       String endDate = (String) workItem.getParameter("End_Date");
       System.out.println("parameters passed into work item: " + sourceIP + "," + startDate + "," + endDate);
       // notify manager that work item has been completed
       manager.completeWorkItem(workItem.getId(),null);
   }
   public void abortWorkItem (WorkItem workItem, WorkItemManager manager) {
       // do nothing, not planning to abort operation at this time
   }
}
*********
*********
The work item definition file has the following entry:
import org.drools.process.core.datatype.impl.type.StringDataType;
[
 [
   "name" : "IP Conversations",
   "parameters" : [
       "Source_IP" : new StringDataType(),
       "Start_Date" : new StringDataType(),
       "End_Date" : new StringDataType()
   ],
   "results" : [
   "Source_IPs" : new StringDataType(),
   "Source_Ports" : new StringDataType(),
   "Dest_IPs" : new StringDataType(),
   "Dest_Ports" : new StringDataType(),
   "Recv_Time" : new StringDataType()
   ],
   "displayName" : "IP Conversations"
 ],
]
********
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/811284#811284]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
"Drools XML error when passing process variables to work item"
To view the discussion, visit: https://community.jboss.org/message/811284#811284
--------------------------------------------------------------
I've been reading through "Section 7.2.3, Using your new work item in your processes" to see how to pass process variables to a work item. Even though the values of each process variable are getting passed each work item, I'm getting the following XML error in the Eclipse console:
| 1 | 02/05 11:43:16,406[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-id.2: There are multiple occurrences of ID value '_4_Source_IPInput'. |
| 4 | 02/05 11:43:16,409[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-attribute.3: The value '_4_Source_IPInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
| 5 | 02/05 11:43:16,410[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-id.2: There are multiple occurrences of ID value '_4_Start_DateInput'. |
| 5 | 02/05 11:43:16,410[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-attribute.3: The value '_4_Start_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
| 6 | 02/05 11:43:16,411[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-id.2: There are multiple occurrences of ID value '_4_End_DateInput'. |
| 6 | 02/05 11:43:16,411[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-attribute.3: The value '_4_End_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
*parameters passed into work item: 111.111.111.111, 2013 05 02 09:00:00, 2013 04 02 09:00:00*
Note the last line in red shows the values are being passed. Does anyone see anything in the folllowing that would cause the Drools XML error?
**********
public class ProcessMain {
   public static final void main(String[] args) throws Exception {
       // load up the knowledge base
       KnowledgeBase kbase = readKnowledgeBase();
       StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       // start a new process instance
       Map<String,Object> params = new HashMap<String,Object>();
       params.put("processIP", "111.111.111.111");
       params.put("processStartDate", "2013 05 02 09:00:00");
       params.put("processEndDate", "2013 04 02 09:00:00");
       ksession.getWorkItemManager().registerWorkItemHandler("IP Conversations", new IPConversationsWorkItemHandler());
       ksession.startProcess("com.sample.bpmn.hello",params);
   }
   private static KnowledgeBase readKnowledgeBase() throws Exception {
       KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
       kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
       return kbuilder.newKnowledgeBase();
   }
}
***********
The Work Item Handler is:
**********
package com.sample;
import org.drools.runtime.process.WorkItem;
import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
import java.sql.*;
import java.util.*;
public class IPConversationsWorkItemHandler implements WorkItemHandler {
   public void executeWorkItem (WorkItem workItem, WorkItemManager manager) {
       // extract parameters
       String sourceIP = (String) workItem.getParameter("Source_IP");
       String startDate = (String) workItem.getParameter("Start_Date");
       String endDate = (String) workItem.getParameter("End_Date");
       System.out.println("parameters passed into work item: " + sourceIP + "," + startDate + "," + endDate);
       // notify manager that work item has been completed
       manager.completeWorkItem(workItem.getId(),null);
   }
   public void abortWorkItem (WorkItem workItem, WorkItemManager manager) {
       // do nothing, not planning to abort operation at this time
   }
}
*********
*********
The work item definition file has the following entry:
import org.drools.process.core.datatype.impl.type.StringDataType;
[
 [
   "name" : "IP Conversations",
   "parameters" : [
       "Source_IP" : new StringDataType(),
       "Start_Date" : new StringDataType(),
       "End_Date" : new StringDataType()
   ],
   "results" : [
   "Source_IPs" : new StringDataType(),
   "Source_Ports" : new StringDataType(),
   "Dest_IPs" : new StringDataType(),
   "Dest_Ports" : new StringDataType(),
   "Recv_Time" : new StringDataType()
   ],
   "displayName" : "IP Conversations"
 ],
]
********
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/811284#811284]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]