"reading weka model (CannotResolveClassException: m_Objects)"

meliniak
meliniak New Altair Community Member
edited November 5 in Community Q&A
I trained a model (simple CART, it's the weka one), saved it in a file and created second process to apply the model. Pretty standard scenario.

Applying model works fine in RM GUI, but when I'm trying to use it in Java, I'm getting, during reading the model from file, such error:
Feb 10, 2014 1:52:22 AM com.rapidminer.Process run
INFO: Process /home/maliniak/.RapidMiner5/repositories/nasa/nasa_apply_model_api.rmp starts
Feb 10, 2014 1:52:22 AM com.rapidminer.Process loadInitialData
INFO: Loading initial data (starting at port 2).
Exception in thread "main" java.lang.IllegalStateException: com.rapidminer.operator.UserError: Could not read file '/home/maliniak/misc/nasa/model/ticker_cart': java.io.IOException: Cannot read from XML stream, wrong format: m_Objects : m_Objects
---- Debugging information ----
message            : m_Objects
cause-exception    : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message      : m_Objects
class              : java.util.ArrayList
required-type      : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
line number        : 1915
class[1]            : weka.core.Instances
converter-type[1]  : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : weka.classifiers.trees.SimpleCart
class[3]            : com.rapidminer.operator.learner.weka.WekaClassifier
converter-type[2]  : com.thoughtworks.xstream.converters.reflection.SerializableConverter
version            : null
-------------------------------.
at net.maliniak.nasa.Engine.main(Engine.java:125)
Caused by: com.rapidminer.operator.UserError: Could not read file '/home/maliniak/misc/nasa/model/ticker_cart': java.io.IOException: Cannot read from XML stream, wrong format: m_Objects : m_Objects
---- Debugging information ----
message            : m_Objects
cause-exception    : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message      : m_Objects
class              : java.util.ArrayList
required-type      : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
line number        : 1915
class[1]            : weka.core.Instances
converter-type[1]  : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : weka.classifiers.trees.SimpleCart
class[3]            : com.rapidminer.operator.learner.weka.WekaClassifier
converter-type[2]  : com.thoughtworks.xstream.converters.reflection.SerializableConverter
version            : null
-------------------------------.
at com.rapidminer.operator.io.ModelLoader.read(ModelLoader.java:81)
at com.rapidminer.operator.io.ModelLoader.read(ModelLoader.java:51)
at com.rapidminer.operator.io.AbstractReader.doWork(AbstractReader.java:126)
at com.rapidminer.operator.Operator.execute(Operator.java:866)
at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:711)
at com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:375)
at com.rapidminer.operator.Operator.execute(Operator.java:866)
at com.rapidminer.Process.run(Process.java:949)
at com.rapidminer.Process.run(Process.java:873)
at com.rapidminer.Process.run(Process.java:832)
at com.rapidminer.Process.run(Process.java:827)
at net.maliniak.nasa.ModelAdapter.getRecommendation(ModelAdapter.java:33)
at net.maliniak.nasa.Engine.fire(Engine.java:70)
at net.maliniak.nasa.Engine.main(Engine.java:123)
Caused by: java.io.IOException: Cannot read from XML stream, wrong format: m_Objects : m_Objects
---- Debugging information ----
message            : m_Objects
cause-exception    : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message      : m_Objects
class              : java.util.ArrayList
required-type      : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
line number        : 1915
class[1]            : weka.core.Instances
converter-type[1]  : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : weka.classifiers.trees.SimpleCart
class[3]            : com.rapidminer.operator.learner.weka.WekaClassifier
converter-type[2]  : com.thoughtworks.xstream.converters.reflection.SerializableConverter
version            : null
-------------------------------
at com.rapidminer.tools.XMLSerialization.fromXML(XMLSerialization.java:147)
at com.rapidminer.operator.AbstractIOObject.read(AbstractIOObject.java:148)
at com.rapidminer.operator.AbstractIOObject.read(AbstractIOObject.java:192)
at com.rapidminer.operator.io.ModelLoader.read(ModelLoader.java:79)
... 14 more
Caused by: com.thoughtworks.xstream.converters.ConversionException: m_Objects : m_Objects
---- Debugging information ----
message            : m_Objects
cause-exception    : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message      : m_Objects
class              : java.util.ArrayList
required-type      : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
line number        : 1915
class[1]            : weka.core.Instances
converter-type[1]  : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : weka.classifiers.trees.SimpleCart
class[3]            : com.rapidminer.operator.learner.weka.WekaClassifier
converter-type[2]  : com.thoughtworks.xstream.converters.reflection.SerializableConverter
version            : null
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.reflection.SerializableConverter$2.defaultReadObject(SerializableConverter.java:370)
at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doUnmarshal(SerializableConverter.java:415)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1052)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1024)
at com.thoughtworks.xstream.XStream$2.readFromStream(XStream.java:1716)
at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readObjectOverride(CustomObjectInputStream.java:104)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:344)
at com.rapidminer.tools.XMLSerialization.fromXML(XMLSerialization.java:141)
... 17 more
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: m_Objects
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:45)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:79)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:72)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:66)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 47 more
Any ideas anyone, please?

Answers

  • Marco_Boeck
    Marco_Boeck New Altair Community Member
    Hi,

    my first guess would be that your Java project is missing libraries which the WEKA extension seems to rely upon. You could try adding all .jars from the /lib folder of RapidMiner and see if it works. Then you can remove them until you only have the ones left you really need.

    Obligatory copyright hint: Please be aware that when using RapidMiner 5 in your own project, your project must be licensed under the AGPL as well. If that is not possible/desirable, an OEM license is required.

    Regards,
    Marco
  • meliniak
    meliniak New Altair Community Member
    It worked, kind of. Adding weka.jar and jars under rapidminer/lib didn't work, but what did work was adding rmx_weka-5.1.1.jar, which I found under ~/.RapidMiner5/managed/.

    Thanks!