<!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;">
Drools XML error when passing process variables to work item
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/dmwpepper">David Harris</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/811284#811284">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table><tbody><tr><td style=";">1</td><td style=";">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'.</td></tr><tr><td style=";">4</td><td style=";">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'.</td></tr><tr><td style=";">5</td><td style=";">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'.</td></tr><tr><td style=";">5</td><td style=";">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'.</td></tr><tr><td style=";">6</td><td style=";">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'.</td></tr><tr><td style=";">6</td><td style=";">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'.</td></tr></tbody></table><p><span style="color: #ff0000;"><strong>parameters passed into work item: 111.111.111.111, 2013 05 02 09:00:00, 2013 04 02 09:00:00</strong></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>**********</p><p>public class ProcessMain {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public static final void main(String[] args) throws Exception {</p><p>        // load up the knowledge base</p><p>        KnowledgeBase kbase = readKnowledgeBase();</p><p>        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</p><p>        // start a new process instance</p><p>        Map<String,Object> params = new HashMap<String,Object>();</p><p>        params.put("processIP", "111.111.111.111");</p><p>        params.put("processStartDate", "2013 05 02 09:00:00");</p><p>        params.put("processEndDate", "2013 04 02 09:00:00");</p><p>        ksession.getWorkItemManager().registerWorkItemHandler("IP Conversations", new IPConversationsWorkItemHandler());</p><p>        ksession.startProcess("com.sample.bpmn.hello",params);</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    private static KnowledgeBase readKnowledgeBase() throws Exception {</p><p>        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</p><p>        kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);</p><p>        return kbuilder.newKnowledgeBase();</p><p>    }</p><p>    </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>***********</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The Work Item Handler is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>**********</p><p>package com.sample;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.drools.runtime.process.WorkItem;</p><p>import org.drools.runtime.process.WorkItemHandler;</p><p>import org.drools.runtime.process.WorkItemManager;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.sql.*;</p><p>import java.util.*;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class IPConversationsWorkItemHandler implements WorkItemHandler {</p><p>    </p><p>    public void executeWorkItem (WorkItem workItem, WorkItemManager manager) {</p><p>        </p><p>        // extract parameters</p><p>        </p><p>        String sourceIP = (String) workItem.getParameter("Source_IP");</p><p>        String startDate = (String) workItem.getParameter("Start_Date");</p><p>        String endDate = (String) workItem.getParameter("End_Date");</p><p>        </p><p>        System.out.println("parameters passed into work item: " + sourceIP + "," + startDate + "," + endDate);</p><p>        // notify manager that work item has been completed</p><p>        </p><p>        manager.completeWorkItem(workItem.getId(),null);</p><p>    }</p><p>    </p><p>    public void abortWorkItem (WorkItem workItem, WorkItemManager manager) {</p><p>        // do nothing, not planning to abort operation at this time</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>*********</p><p>*********</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The work item definition file has the following entry:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.drools.process.core.datatype.impl.type.StringDataType;</p><p>[</p><p>  [</p><p>    "name" : "IP Conversations",</p><p>    "parameters" : [</p><p>        "Source_IP" : new StringDataType(),</p><p>        "Start_Date" : new StringDataType(),</p><p>        "End_Date" : new StringDataType()</p><p>    ],</p><p>    "results" : [</p><p>    "Source_IPs" : new StringDataType(),</p><p>    "Source_Ports" : new StringDataType(),</p><p>    "Dest_IPs" : new StringDataType(),</p><p>    "Dest_Ports" : new StringDataType(),</p><p>    "Recv_Time"  : new StringDataType()</p><p>    ],</p><p>    "displayName" : "IP Conversations"</p><p>  ],</p><p>]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>********</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/811284#811284">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>