Using Drools 5.5.0.Final with Guvnor 5.5.0.Final with a sample mortgage package.
When sending a json REST request with the following package execution command:
{ "batch-execution": { "lookup":"ksession1", "commands":[ { "insert":{ "out-identifier":"outApplicant", "return-object":"true", "object": { "Applicant":{ "age":17 } } } }, { "fire-all-rules":"" } ] } }
returns: 500 Internal server error
com.thoughtworks.xstream.converters.ConversionException: Applicant : Applicant ---- Debugging information ---- message : Applicant cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException cause-message : Applicant class : org.drools.command.runtime.rule.InsertObjectCommand required-type : org.drools.command.runtime.rule.InsertObjectCommand converter-type : org.drools.runtime.help.impl.XStreamJson$JsonInsertConverter line number : -1 class[1] : org.drools.command.runtime.BatchExecutionCommandImpl converter-type[1] : org.drools.runtime.help..XSt...$JsonBatchExecutionCommandConverter version : null
The Applicant's class is defined in the mortgage loan package in XSD, for example:
age:Whole number (integer) applicationDate:Date creditRating:Text name:Text approved:True or False
How can I tell drools where to find the candidate class? (which is defined in the mortgage sample as an XSD file)
Knowledge-services.xml now looks like this:
<drools:grid-node id="node1"/> <drools:kbase id="kbase1" node="node1"> <drools:resources> <drools:resource type="PKG" source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/packages/mortgages"/> </drools:resources> </drools:kbase>
I suspect that changing the json REST request to fully specify the package name for the Applicant class may work.
... "object": { "something.somethingelse.Applicant":{ "age":17 } } ...
But, it seems, canβt find where the full package name for the Applicant is declared?
A valid answer should show an example that works without having to write java code, since the whole point of the REST interface is access to drooling through the web service interface.
Is there a spring configuration or some other way to write a json request that will work?