TC ONG
2013-04-09 01:29:28 UTC
TC ONG [https://community.jboss.org/people/devilkazuya99] created the discussion
"java.io.OptionalDataException when do ObjectInputStream.readObject()"
To view the discussion, visit: https://community.jboss.org/message/807101#807101
--------------------------------------------------------------
I am using jBPM 5.4.0 final here.
Loading Image... Loading Image...
In me bpmn file I have a String variable in my process. I set it in "onEntry" scritp of my Human Task. Then map it to "Content" in data input association.
   <userTask id="_5" name="User Task" >
     <extensionElements>
       <tns:onEntry-script scriptFormat="http://www.java.com/java">
         <script>
*Â Â Â Â Â Â Â Â Â String s = "How do you do?";*
*Â Â Â Â Â Â Â Â Â kcontext.setVariable("content", s);*
         </script>
       </tns:onEntry-script>
     </extensionElements>
     <ioSpecification>
*Â Â Â Â Â Â Â <dataInput id="_5_ContentInput" name="Content" />*
*Â Â Â Â Â Â Â <dataOutput id="_5_answerOutput" name="answer" />*
       <inputSet>
         <dataInputRefs>_5_ContentInput</dataInputRefs>
       </inputSet>
       <outputSet>
         <dataOutputRefs>_5_answerOutput</dataOutputRefs>
       </outputSet>
     </ioSpecification>
*Â Â Â Â Â <dataInputAssociation>*
*Â Â Â Â Â Â Â <sourceRef>content</sourceRef>*
*Â Â Â Â Â Â Â <targetRef>_5_ContentInput</targetRef>*
*Â Â Â Â Â </dataInputAssociation>*
     <dataInputAssociation>
       <targetRef>_5_ContentInput</targetRef>
       <assignment>
         <from xsi:type="tFormalExpression"></from>
         <to xsi:type="tFormalExpression">_5_ContentInput</to>
       </assignment>
     </dataInputAssociation>
     <dataOutputAssociation>
       <sourceRef>_5_answerOutput</sourceRef>
       <targetRef>answer</targetRef>
     </dataOutputAssociation>
     <potentialOwner>
       <resourceAssignmentExpression>
         <formalExpression>nemo</formalExpression>
       </resourceAssignmentExpression>
     </potentialOwner>
   </userTask>
I hope to get the "Content" at the programming side.
List<TaskSummary> taskSummaryList = localTaskService.getTasksAssignedAsPotentialOwner("nemo", "en-UK");
                           for (TaskSummary taskSummary : taskSummaryList) {
                                    System.out.println(taskSummary.getId() + "\t" + taskSummary.getName() + "\t" + taskSummary.getStatus());
                                    Task task = localTaskService.getTask(taskSummary.getId());
                                    long documentContentId = task.getTaskData().getDocumentContentId();
*Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Content content = localTaskService.getContent(documentContentId);*
                                    System.out.println(content.getId() + " => " + content.toString());
                                    if (content != null){
                             ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
                             ObjectInputStream ois;
                             try {
                                 ois = new ObjectInputStream(bais);
                                 *Object obj = ois.readObject();*
                                 logger.debug("Object = " + obj.getClass());
                             } catch (IOException e) {
                                 *e.printStackTrace();*
                            } catch (ClassNotFoundException e) {
                                 e.printStackTrace();
                             }
                         }
                                    localTaskService.start(taskSummary.getId(), "nemo");
                                    Map<String, Object> results = new HashMap<String, Object>();
                                    results.put("answer", "GOOD");
                                    localTaskService.completeWithResults(taskSummary.getId(), "nemo", results);
                           }
The result on the console is:
1 => ***@74baaca4
java.io.OptionalDataException
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1358)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
         at HelloJBPM5.main(HelloJBPM5.java:73)
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/807101#807101]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
"java.io.OptionalDataException when do ObjectInputStream.readObject()"
To view the discussion, visit: https://community.jboss.org/message/807101#807101
--------------------------------------------------------------
I am using jBPM 5.4.0 final here.
Loading Image... Loading Image...
In me bpmn file I have a String variable in my process. I set it in "onEntry" scritp of my Human Task. Then map it to "Content" in data input association.
   <userTask id="_5" name="User Task" >
     <extensionElements>
       <tns:onEntry-script scriptFormat="http://www.java.com/java">
         <script>
*Â Â Â Â Â Â Â Â Â String s = "How do you do?";*
*Â Â Â Â Â Â Â Â Â kcontext.setVariable("content", s);*
         </script>
       </tns:onEntry-script>
     </extensionElements>
     <ioSpecification>
*Â Â Â Â Â Â Â <dataInput id="_5_ContentInput" name="Content" />*
*Â Â Â Â Â Â Â <dataOutput id="_5_answerOutput" name="answer" />*
       <inputSet>
         <dataInputRefs>_5_ContentInput</dataInputRefs>
       </inputSet>
       <outputSet>
         <dataOutputRefs>_5_answerOutput</dataOutputRefs>
       </outputSet>
     </ioSpecification>
*Â Â Â Â Â <dataInputAssociation>*
*Â Â Â Â Â Â Â <sourceRef>content</sourceRef>*
*Â Â Â Â Â Â Â <targetRef>_5_ContentInput</targetRef>*
*Â Â Â Â Â </dataInputAssociation>*
     <dataInputAssociation>
       <targetRef>_5_ContentInput</targetRef>
       <assignment>
         <from xsi:type="tFormalExpression"></from>
         <to xsi:type="tFormalExpression">_5_ContentInput</to>
       </assignment>
     </dataInputAssociation>
     <dataOutputAssociation>
       <sourceRef>_5_answerOutput</sourceRef>
       <targetRef>answer</targetRef>
     </dataOutputAssociation>
     <potentialOwner>
       <resourceAssignmentExpression>
         <formalExpression>nemo</formalExpression>
       </resourceAssignmentExpression>
     </potentialOwner>
   </userTask>
I hope to get the "Content" at the programming side.
List<TaskSummary> taskSummaryList = localTaskService.getTasksAssignedAsPotentialOwner("nemo", "en-UK");
                           for (TaskSummary taskSummary : taskSummaryList) {
                                    System.out.println(taskSummary.getId() + "\t" + taskSummary.getName() + "\t" + taskSummary.getStatus());
                                    Task task = localTaskService.getTask(taskSummary.getId());
                                    long documentContentId = task.getTaskData().getDocumentContentId();
*Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Content content = localTaskService.getContent(documentContentId);*
                                    System.out.println(content.getId() + " => " + content.toString());
                                    if (content != null){
                             ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
                             ObjectInputStream ois;
                             try {
                                 ois = new ObjectInputStream(bais);
                                 *Object obj = ois.readObject();*
                                 logger.debug("Object = " + obj.getClass());
                             } catch (IOException e) {
                                 *e.printStackTrace();*
                            } catch (ClassNotFoundException e) {
                                 e.printStackTrace();
                             }
                         }
                                    localTaskService.start(taskSummary.getId(), "nemo");
                                    Map<String, Object> results = new HashMap<String, Object>();
                                    results.put("answer", "GOOD");
                                    localTaskService.completeWithResults(taskSummary.getId(), "nemo", results);
                           }
The result on the console is:
1 => ***@74baaca4
java.io.OptionalDataException
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1358)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
         at HelloJBPM5.main(HelloJBPM5.java:73)
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/807101#807101]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]