9 Replies Latest reply on Oct 25, 2012 6:30 AM by Maciej Swiderski

    XML Deserialization of Result Map Fails 5.4.0.Beta1

    Newbie

      We are getting this exception:

       

      16:12:52,091 ERROR [com.irdeto.taskhandler.AbstractTaskHandler] (pool-13-thread-1) An exception occurred downstream of task ConfigurationTaskHandler: Configuration.  This likely occurred in a script task or gateway.: com.thoughtworks.xstream.io.StreamException:  : only whitespace content allowed before start tag and not h (position: START_DOCUMENT seen h... @1:1)

              at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:58) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.XStream.fromXML(XStream.java:895) [xstream-1.4.1.jar:]

              at com.thoughtworks.xstream.XStream.fromXML(XStream.java:886) [xstream-1.4.1.jar:]

              at org.drools.process.core.datatype.impl.type.ObjectDataType.readValue(ObjectDataType.java:77) [drools-core-5.5.0.Beta1.jar:5.5.0.Beta1]

              at org.jbpm.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:223) [jbpm-flow-5.4.0-20120925.045710-447.jar:5.4.0-SNAPSHOT]

              at org.jbpm.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:309) [jbpm-flow-5.4.0-20120925.045710-447.jar:5.4.0-SNAPSHOT]

       

      This is failing when jbpm-flow tries to deserialize the result map data on completing a task.  Some of the values we are mapping are URLs, e.g. "http..." so I'm guessing that's where the "h" comes from in the exception.

       

      This worked in an earlier version of jbpm 5.4.0-SNAPSHOT....

       

      Any help much appreciated.

        • 1. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
          Maciej Swiderski Master

          could you provide your property (process variable) definitions - this is where process variable type is defined as 5.4 resolves variables based on its type to properly create correct types such as Boolean, Integer, Float.

           

          Take a look at following test cases and one example of process definition

           

          HTH

          • 2. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
            Newbie

            Hi Maciej

             

            Most are String, e.g.

               <itemDefinition id="_9-sportClipMDItem" structureRef="String" />

            Some are list, e.g.

               <itemDefinition id="_9-sportclipListItem" structureRef="java.util.List" />

             

            We have a fair few that are our own fully qualified data structure objects, e.g.

              <itemDefinition id="_40-contentMDListItem" structureRef="com.test.domain.Envelope" />

             

            I'm guessing the error we're getting comes from this one:

              <itemDefinition id="_23-configItem" structureRef="com.test.domain.CheckedMap" />

             

            Is this what you are referring to?

             

             

            Thanks


            Tim

            • 3. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
              Maciej Swiderski Master

              yes, this is what I asked for. This error will be thrown only if you have defined custom type and you pass String as value for it thus it will try to use XStream to build an object out of the string. Could you please attache simple test case for it or at least describe in details on how you invoke it, mainly how you pass parameters (and what parameters) when completing this work item.

               

              HTH

              • 4. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
                Newbie

                Hi Maciej

                 

                Thanks for the info, we'll fix the workflow.  It is a shame that we don't have an option to handle strings as content type String or Object.

                 

                Tim

                • 5. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
                  Maciej Swiderski Master

                  Tim, you can use String as content type it just requires to be configures as string type in the item definition. Once you have custom type defined you need to either use that object directly when providing result to your work item or provide xml representation as string so XStream can build the object for you. If you use java.lang.Object as structureRef it will use it as object without any type checks or transformations.

                   

                  Let me know if there are any other concerns in this.

                   

                  HTH

                  • 6. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
                    Newbie

                    Hi Maciej

                     

                    So to be clear:

                     

                    In my custom work item handler I do:
                         workItem.getResults().put("SomeKey", value);

                    where value is an object of a custom type, which is just some Java class e.g. com.test.CustomType.

                     

                    In my workflow I create a workflow variable where I use the Eclipse UI to select Object, and set com.test.CustomType in the Classname field.

                     

                    In my task's result map, I map my parameter named "SomeKey" to the workflow variable.

                     

                    At least that's what I've been doing so far with my older version of 5.4.0, which has been working fine - do I need to do anything new now to make this CustomType work with the new XStream approach?

                     

                    Sorry for labouring this, but I'd love this to work!

                     

                    Thanks

                     

                    Tim

                    • 7. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
                      Maciej Swiderski Master

                      If you provide object of the custom type then XStream is not involved at all. XStream (or any data type) will be involed only if the parameter is of type string as it will try to build object representation based on string.

                       

                      take a look at this example process definition it uses custom class as process variable for this you can either execute it with object of type string (an xml representation of it) or give it directly the instance of that type. Here is a corresponding test case that uses string/xml representation but I just tired with instance of person class and it works as expected.

                       

                      Can you see any difference with your process or code used to complete work item?

                      • 8. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
                        Newbie

                        OK, so Strings - 2 separate things we observe.

                         

                        1. Using the eclipse editor, if I define the workflow variable as a String, then save, close the workflow and edit the variable, it shows up as Object of class String, i.e. is not consistent.  I guess this is because in both cases it writes a structureRef="String"

                        2. This code in WorkItemNodeInstance method triggerCompleted:

                         

                                                Object value = workItem.getResult(association.getSources().get(0));

                                                if (value == null) {

                                                    try {

                                                        value = MVEL.eval(association.getSources().get(0), new WorkItemResolverFactory(workItem));

                                                    } catch (Throwable t) {

                                                        // do nothing

                                                    }

                                                }

                                                Variable varDef = variableScopeInstance.getVariableScope().findVariable(association.getTarget());

                                                DataType dataType = varDef.getType();

                                                // exclude java.lang.Object as it is considered unknown type

                                                if (!dataType.getStringType().endsWith("java.lang.Object") && value instanceof String) {

                                                    value = dataType.readValue((String) value);

                                                }

                                                variableScopeInstance.setVariable(association.getTarget(), value);


                        For my String structureRef variables, I see my XStream exception, so I know it is hitting:

                                                    value = dataType.readValue((String) value);


                        So how am I meant to use a String that doesn't have XML in it...just a plain string that I want to pass back to the workflow?  The if statement:

                                                if (!dataType.getStringType().endsWith("java.lang.Object") && value instanceof String) {


                        says to execute this XStream method if the type is not defined as java.lang.Object (which it isn't, it is defined as structureRef String) and the value is an instance of String, which it is, I'm trying to pass a string back.

                         

                        To me this appears like the code doesn't cater for handling strings that are not representing serialized content...it appears that if we set the structureRef to java.lang.Object then this will work, but I suspect we won't be able to use the workflow variables in script tasks without casting back to String.

                         

                        Thanks for all your help.

                         

                        Tim

                        • 9. Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
                          Maciej Swiderski Master

                          ok, now I see what is wrong - Beta1 had indeed problem handling string types, it was fixed just after it was out. Took me a while to find this out. I believe CR1 is now available and that has it fixed for sure. Please have a try with 5.4.0.CR1

                           

                          HTH