Folks,<div>I&#39;m trying to use Drools in a mostly Java-less environment (rules are written in .drl files, facts will be inserted from XML files). I&#39;m running into an issue where the XStream unmarshaller is unable to convert my XML to a BatchExecutionCommand because it cannot find the class for a type declared in the .drl file.</div>
<div>Is there any configuration required to make sure the XStream marshaller knows about the dynamically generated classes from the .drl?</div><div>I&#39;d appreciated any clues. I cannot add POJO classes for my types due to the nature of the app.</div>
<div>Thanks.</div><div><br></div><div><br></div><div>DRL file</div><div>-----------</div><div><div>package com.example</div><div>declare Answers </div></div><div>....</div><div>end</div><div>/* some rules after this */</div>
<div>...</div><div><br></div><div>XML file</div><div>-----------</div><div><div>&lt;batch-execution&gt;</div><div>  &lt;insert&gt;</div><div>   &lt;com.example.Answers&gt;</div></div><div>       ....</div><div><br></div><div>
<br></div><div>Runner code</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public static void Run(String xmlFactsFile, String drlFilename)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>// Compile the drl file</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>kbuilder.add( ResourceFactory.newFileResource(drlFilename),</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>ResourceType.DRL );</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>if ( kbuilder.hasErrors() ) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>System.err.println( kbuilder.getErrors().toString() );</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>throw new RuntimeException(&quot;Cannot compile \&quot;&quot; + drlFilename + &quot;\&quot;&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>// kbase setup from the compiled rules</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>File facts = new File(xmlFactsFile);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>BatchExecutionCommand command = (BatchExecutionCommand) BatchExecutionHelper.newXStreamMarshaller().fromXML(facts);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>ExecutionResults bresults = ksession.execute(command);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>System.out.println(BatchExecutionHelper.newXStreamMarshaller().toXML(bresults));</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div><br></div><div>Error at runtime</div><div>----------------------</div><div><div>Exception in thread &quot;main&quot; com.thoughtworks.xstream.converters.ConversionException: com.example.Answers : com.example.Answers</div>
<div>---- Debugging information ----</div><div>message             : com.example.Answers</div><div>cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException</div><div>cause-message       : com.example.Answers</div>
<div>class               : org.drools.command.runtime.rule.InsertObjectCommand</div><div>required-type       : org.drools.command.runtime.rule.InsertObjectCommand</div><div>converter-type      : org.drools.runtime.help.impl.XStreamXML$InsertConverter</div>
<div>path                : /batch-execution/insert/com.example.Answers</div><div>line number         : 3</div><div>class[1]            : org.drools.command.runtime.BatchExecutionCommandImpl</div><div>converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter</div>
<div>version             : null</div><div>-------------------------------</div><div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)</div><div>        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)</div>
<div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)</div><div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)</div><div>
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:318)</div><div>        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:230)</div>
<div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)</div><div>        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)</div>
<div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)</div><div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)</div><div>
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)</div><div>        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)</div>
<div>        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1035)</div><div>        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1019)</div><div>        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:930)</div>
<div>        at com.intentsoft.RulesEngine.RulesExecution.Run(RulesExecution.java:34)</div><div>        at com.intentsoft.RulesEngine.Main.main(Main.java:10)</div><div>Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: com.example.Answers</div>
<div>        at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)</div>
<div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)</div><div>
        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div>
<div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div>
<div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)</div>
<div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div>
<div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div>
<div>        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)</div><div>        at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:45)</div><div>        at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)</div>
<div>        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)</div><div>        at org.drools.runtime.help.impl.XStreamXML$InsertConverter.unmarshal(XStreamXML.java:135)</div>
<div>        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)</div><div>        ... 16 more</div></div><div><br></div>