Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Incomplete
-
Affects Version/s: 1.4.1
-
Fix Version/s: None
-
Component/s: Core
-
Labels:None
Description
I have the following xml which read into memory fine:
<solverBenchmarkSuite> <solverBenchmark> <name>config1</name> <solver> <planningEntityClass>org.drools.planner.examples.cloudbalancing.domain.CloudAssignment</planningEntityClass> ... </solver> </solverBenchmark> <solverBenchmark> <name>config2</name> <solver> <planningEntityClass>org.drools.planner.examples.cloudbalancing.domain.CloudAssignment</planningEntityClass> ... </solver> </solverBenchmark> </solverBenchmarkSuite>
On SolverConfig (the class that corresponds to <solver>), it looks like this:
@XStreamAlias("solver") public class SolverConfig { @XStreamImplicit(itemFieldName = "planningEntityClass") protected Set<Class<?>> planningEntityClassSet = null; }
Note that there can be multiple <planningEntityClass> configured on 1 <solver>.
To avoid an extra <set> entity in the xml, @XStreamImplicit has been used.
However, when writing that original class file, I get:
Exception in thread "main" com.thoughtworks.xstream.core.AbstractReferenceMarshaller$ReferencedImplicitElementException: Cannot reference implicit element
---- Debugging information ----
implicit-element : [class org.drools.planner.examples.nurserostering.domain.Assignment]
referencing-element : /solverBenchmarkSuite/solverBenchmark/solver
-------------------------------
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.registerImplicit(AbstractReferenceMarshaller.java:106)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:127)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:116)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:225)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:204)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:167)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:116)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:225)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:204)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:163)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:116)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:877)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:866)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:839)
at org.drools.planner.benchmark.SolverBenchmarkSuite.writeBenchmarkResult(SolverBenchmarkSuite.java:510)
at org.drools.planner.benchmark.SolverBenchmarkSuite.benchmarkingEnded(SolverBenchmarkSuite.java:407)
at org.drools.planner.benchmark.SolverBenchmarkSuite.benchmark(SolverBenchmarkSuite.java:327)
at org.drools.planner.benchmark.XmlSolverBenchmarker.benchmark(XmlSolverBenchmarker.java:78)
at org.drools.planner.examples.common.app.CommonBenchmarkApp.process(CommonBenchmarkApp.java:36)
at org.drools.planner.examples.nurserostering.app.NurseRosteringBenchmarkApp.main(NurseRosteringBenchmarkApp.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Hi Geoffry,
in first place I cannot see there's something wrong. The declaration for the implicit set is fine and XStream should be able to read and write the elements. Nevertheless, the implicit declaration will hide the 'planningEntityClassSet' i.e. this set has no representation in the XML. But it seems that there is nevertheless at least one element in your complete object graph that refers it. Can you write the XML once without the implicit set (just remove the annotation and configure two XStream instances - one with addImplicitColleciton call used to read, the other one for writing). Somewhere you should see somewhere an attribute 'reference' that refers '?/solver/planningEntityClassSet'.