XStream
  1. XStream
  2. XSTR-666

@XStreamImplicit: can read an xml file but cannot write it (crashes with AbstractReferenceMarshaller$ReferencedImplicitElementException)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major 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)
      

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Geoffrey De Smet
        • Votes:
          1 Vote for this issue
          Watchers:
          3 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: