<!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;">
    Re: XML Deserialization of Result Map Fails 5.4.0.Beta1
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/tcharman">Timothy Charman</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/772277#772277">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>OK, so Strings - 2 separate things we observe.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.&#160; I guess this is because in both cases it writes a structureRef="String"</p><p>2. This code in WorkItemNodeInstance method triggerCompleted:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="line" id="LC211" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">Object</span> <span class="n">value</span> <span class="o" style="font-weight: bold;">=</span> <span class="n">workItem</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getResult</span><span class="o" style="font-weight: bold;">(</span><span class="n">association</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getSources</span><span class="o" style="font-weight: bold;">().</span><span class="na" style="color: #008080;">get</span><span class="o" style="font-weight: bold;">(</span><span class="mi" style="color: #009999;">0</span><span class="o" style="font-weight: bold;">));</span></p><p class="line" id="LC212" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="k" style="font-weight: bold;">if</span> <span class="o" style="font-weight: bold;">(</span><span class="n">value</span> <span class="o" style="font-weight: bold;">==</span> <span class="kc" style="font-weight: bold;">null</span><span class="o" style="font-weight: bold;">)</span> <span class="o" style="font-weight: bold;">{</span></p><p class="line" id="LC213" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="k" style="font-weight: bold;">try</span> <span class="o" style="font-weight: bold;">{</span></p><p class="line" id="LC214" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">value</span> <span class="o" style="font-weight: bold;">=</span> <span class="n">MVEL</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">eval</span><span class="o" style="font-weight: bold;">(</span><span class="n">association</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getSources</span><span class="o" style="font-weight: bold;">().</span><span class="na" style="color: #008080;">get</span><span class="o" style="font-weight: bold;">(</span><span class="mi" style="color: #009999;">0</span><span class="o" style="font-weight: bold;">),</span> <span class="k" style="font-weight: bold;">new</span> <span class="n">WorkItemResolverFactory</span><span class="o" style="font-weight: bold;">(</span><span class="n">workItem</span><span class="o" style="font-weight: bold;">));</span></p><p class="line" id="LC215" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="o" style="font-weight: bold;">}</span> <span class="k" style="font-weight: bold;">catch</span> <span class="o" style="font-weight: bold;">(</span><span class="n">Throwable</span> <span class="n">t</span><span class="o" style="font-weight: bold;">)</span> <span class="o" style="font-weight: bold;">{</span></p><p class="line" id="LC216" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="c1" style="color: #999988; font-style: italic;">// do nothing</span></p><p class="line" id="LC217" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="o" style="font-weight: bold;">}</span></p><p class="line" id="LC218" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="o" style="font-weight: bold;">}</span></p><p class="line" id="LC219" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">Variable</span> <span class="n">varDef</span> <span class="o" style="font-weight: bold;">=</span> <span class="n">variableScopeInstance</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getVariableScope</span><span class="o" style="font-weight: bold;">().</span><span class="na" style="color: #008080;">findVariable</span><span class="o" style="font-weight: bold;">(</span><span class="n">association</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getTarget</span><span class="o" style="font-weight: bold;">());</span></p><p class="line" id="LC220" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">DataType</span> <span class="n">dataType</span> <span class="o" style="font-weight: bold;">=</span> <span class="n">varDef</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getType</span><span class="o" style="font-weight: bold;">();</span></p><p class="line" id="LC221" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="c1" style="color: #999988; font-style: italic;">// exclude java.lang.Object as it is considered unknown type</span></p><p class="line" id="LC222" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="k" style="font-weight: bold;">if</span> <span class="o" style="font-weight: bold;">(!</span><span class="n">dataType</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getStringType</span><span class="o" style="font-weight: bold;">().</span><span class="na" style="color: #008080;">endsWith</span><span class="o" style="font-weight: bold;">(</span><span class="s" style="color: #dd1144;">"java.lang.Object"</span><span class="o" style="font-weight: bold;">)</span> <span class="o" style="font-weight: bold;">&amp;&amp;</span> <span class="n">value</span> <span class="k" style="font-weight: bold;">instanceof</span> <span class="n">String</span><span class="o" style="font-weight: bold;">)</span> <span class="o" style="font-weight: bold;">{</span></p><p class="line" id="LC223" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">value</span> <span class="o" style="font-weight: bold;">=</span> <span class="n">dataType</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">readValue</span><span class="o" style="font-weight: bold;">((</span><span class="n">String</span><span class="o" style="font-weight: bold;">)</span> <span class="n">value</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC224" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="o" style="font-weight: bold;">}</span></p><p class="line" id="LC225" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">variableScopeInstance</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">setVariable</span><span class="o" style="font-weight: bold;">(</span><span class="n">association</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getTarget</span><span class="o" style="font-weight: bold;">(),</span> <span class="n">value</span><span class="o" style="font-weight: bold;">);</span></p><p><span class="o" style="font-weight: bold;"><br/></span></p><p>For my String structureRef variables, I see my XStream exception, so I know it is hitting:</p><p class="line" id="LC223" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">value</span> <span class="o" style="font-weight: bold;">=</span> <span class="n">dataType</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">readValue</span><span class="o" style="font-weight: bold;">((</span><span class="n">String</span><span class="o" style="font-weight: bold;">)</span> <span class="n">value</span><span class="o" style="font-weight: bold;">);</span></p><p><span class="o" style="font-weight: bold;"><br/></span></p><p>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?&#160; The if statement:</p><p class="line" id="LC222" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="k" style="font-weight: bold;">if</span> <span class="o" style="font-weight: bold;">(!</span><span class="n">dataType</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">getStringType</span><span class="o" style="font-weight: bold;">().</span><span class="na" style="color: #008080;">endsWith</span><span class="o" style="font-weight: bold;">(</span><span class="s" style="color: #dd1144;">"java.lang.Object"</span><span class="o" style="font-weight: bold;">)</span> <span class="o" style="font-weight: bold;">&amp;&amp;</span> <span class="n">value</span> <span class="k" style="font-weight: bold;">instanceof</span> <span class="n">String</span><span class="o" style="font-weight: bold;">)</span> <span class="o" style="font-weight: bold;">{</span></p><p><span class="o" style="font-weight: bold;"><br/></span></p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks for all your help.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Tim</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/772277#772277">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>