I'm tryng samples projects to understand how to use the Optaplanner features (using ver. 7.11-Final on wildfly11). I installed some built-in samples and now I encountered a very strange error after using an
employee rostering
sample modified by me, when I try to post different xml via REST API (using SOAP-UI).
Using the following xml (excerpt) it work well, I can submit the xml without problem and retrieve the best solution calling the related endpoint:
<TeamRoster>
<employeeList>
<Employee>
<name>Luigi</name>
</Employee>
<Employee>
<name>Mauro</name>
</Employee>
<Employee>
<name>Pietro</name>
</Employee>
<Employee>
<name>Gino</name>
</Employee>
</employeeList>
<teamList>
<Team>
<name>Squadra 1</name>
<employeeList>
<Employee reference="../../../../employeeList/Employee"/>
<Employee reference="../../../../employeeList/Employee[2]"/>
</employeeList>
.........
Instead, using the following modified xml (with id/reference):
<TeamRoster id="1">
<employeeList id="2">
<Employee id="3">
<id>0</id>
<name>Luigi</name>
</Employee>
<Employee id="4">
<id>1</id>
<name>Mauro</name>
</Employee>
<Employee id="5">
<id>2</id>
<name>Pietro</name>
</Employee>
<Employee id="6">
<id>3</id>
<name>Gino</name>
</Employee>
</employeeList>
<teamList id="7">
<Team id="8">
<id>0</id>
<name>Squadra 1</name>
<employeeList id="9">
<Employee reference="3"/>
<Employee reference="4"/>
</employeeList>
The response of kie server is a message error:
com.thoughtworks.xstream.converters.ConversionException: Invalid reference
with details:
message : Invalid reference
reference : 3
referenced-type : com.linkit.trostering.Employee
referenceable : true
class : java.util.ArrayList
required-type : java.util.ArrayList
converter-type : com.thoughtworks.xstream.converters.collections.CollectionConverter
path : /TeamRoster/teamList/Team/employeeList/Employee
line number : 25
class[1] : com.linkit.trostering.Team
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : com.linkit.trostering.TeamRoster
version : 7.11.0.Final
I've seen that other samples included in optaplanner samples project use this option (if I understand it's a xtream feature) to reference fact already defined using id instead the xml path.
Now my doubt is if Optaplanner wb with kie server is shipped with xstream different settings? Is there any option that must be send via REST to use this feature of xtream? Any other thing?
Thanks in advance for any help that is very appreciated
Your first xml uses XPath references. Your second xml uses id references. The second one requires a different XStream setup: