jjazzboss / JJazzLabToolkit

JJazzLab core in one jar library
https://www.jjazzlab.org
GNU Lesser General Public License v2.1
4 stars 0 forks source link

opening existing sng files throws exception in 4.1.0 ToolkitDemoApp #1

Closed jcundill closed 1 month ago

jcundill commented 2 months ago

Edited ToolkitDemoApp to load a 'sng' file exported from the latest released version of jjazzlab rather than create a song from scratch.

This fails with the following XStream exception rather than loading the song file. Same issue if I let the ToolkitDemoApp create a song from scratch but then try and save that created song to file.

INFO ToolkitDemoApp  ------------------------------------------------------- 
INFO ToolkitDemoApp  Loading song file /home/jon/Desktop/NewSong1.sng... 
Exception in thread "main" java.lang.RuntimeException: org.jjazz.song.api.SongCreationException: com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.NullPointerException
cause-message       : Cannot invoke "Object.toString()" because the return value of "java.util.Map$Entry.getValue()" is null
method              : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy.readObject()
class               : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy
required-type       : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy
converter-type      : com.thoughtworks.xstream.converters.reflection.SerializableConverter
path                : /Song/spChordLeadSheet/spItems/CLI_ChordSymbolImpl/spChord/spRenderingInfo/ChordRenderingInfoSP/enum-set
line number         : 27
class[1]            : org.jjazz.chordleadsheet.api.item.ExtChordSymbol$SerializationProxy
required-type[1]    : org.jjazz.chordleadsheet.api.item.ExtChordSymbol$SerializationProxy
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : org.jjazz.chordleadsheet.item.CLI_ChordSymbolImpl$SerializationProxy
required-type[2]    : org.jjazz.chordleadsheet.item.CLI_ChordSymbolImpl$SerializationProxy
class[3]            : java.util.ArrayList
required-type[3]    : java.util.ArrayList
converter-type[2]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[4]            : org.jjazz.chordleadsheet.ChordLeadSheetImpl$SerializationProxy
required-type[4]    : org.jjazz.chordleadsheet.ChordLeadSheetImpl$SerializationProxy
class[5]            : org.jjazz.song.api.Song$SerializationProxy
required-type[5]    : org.jjazz.song.api.Song$SerializationProxy
version             : not available
-------------------------------
    at org.jjazzlab.toolkitdemo.ToolkitDemoApp.main(ToolkitDemoApp.java:127)
Caused by: org.jjazz.song.api.SongCreationException: com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.NullPointerException
cause-message       : Cannot invoke "Object.toString()" because the return value of "java.util.Map$Entry.getValue()" is null
method              : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy.readObject()
class               : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy
required-type       : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy
converter-type      : com.thoughtworks.xstream.converters.reflection.SerializableConverter
path                : /Song/spChordLeadSheet/spItems/CLI_ChordSymbolImpl/spChord/spRenderingInfo/ChordRenderingInfoSP/enum-set
line number         : 27
class[1]            : org.jjazz.chordleadsheet.api.item.ExtChordSymbol$SerializationProxy
required-type[1]    : org.jjazz.chordleadsheet.api.item.ExtChordSymbol$SerializationProxy
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : org.jjazz.chordleadsheet.item.CLI_ChordSymbolImpl$SerializationProxy
required-type[2]    : org.jjazz.chordleadsheet.item.CLI_ChordSymbolImpl$SerializationProxy
class[3]            : java.util.ArrayList
required-type[3]    : java.util.ArrayList
converter-type[2]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[4]            : org.jjazz.chordleadsheet.ChordLeadSheetImpl$SerializationProxy
required-type[4]    : org.jjazz.chordleadsheet.ChordLeadSheetImpl$SerializationProxy
class[5]            : org.jjazz.song.api.Song$SerializationProxy
required-type[5]    : org.jjazz.song.api.Song$SerializationProxy
version             : not available
-------------------------------
    at org.jjazz.song.api.Song.loadFromFile(Song.java:831)
    at org.jjazzlab.toolkitdemo.ToolkitDemoApp.main(ToolkitDemoApp.java:123)
Caused by: com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.NullPointerException
cause-message       : Cannot invoke "Object.toString()" because the return value of "java.util.Map$Entry.getValue()" is null
method              : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy.readObject()
class               : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy
required-type       : org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy
converter-type      : com.thoughtworks.xstream.converters.reflection.SerializableConverter
path                : /Song/spChordLeadSheet/spItems/CLI_ChordSymbolImpl/spChord/spRenderingInfo/ChordRenderingInfoSP/enum-set
line number         : 27
class[1]            : org.jjazz.chordleadsheet.api.item.ExtChordSymbol$SerializationProxy
required-type[1]    : org.jjazz.chordleadsheet.api.item.ExtChordSymbol$SerializationProxy
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : org.jjazz.chordleadsheet.item.CLI_ChordSymbolImpl$SerializationProxy
required-type[2]    : org.jjazz.chordleadsheet.item.CLI_ChordSymbolImpl$SerializationProxy
class[3]            : java.util.ArrayList
required-type[3]    : java.util.ArrayList
converter-type[2]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[4]            : org.jjazz.chordleadsheet.ChordLeadSheetImpl$SerializationProxy
required-type[4]    : org.jjazz.chordleadsheet.ChordLeadSheetImpl$SerializationProxy
class[5]            : org.jjazz.song.api.Song$SerializationProxy
required-type[5]    : org.jjazz.song.api.Song$SerializationProxy
version             : not available
-------------------------------
    at com.thoughtworks.xstream.core.util.SerializationMembers.callReadObject(SerializationMembers.java:136)
    at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doUnmarshal(SerializableConverter.java:443)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:117)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:99)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:92)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:86)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:81)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1464)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1441)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1321)
    at org.jjazz.song.api.Song.loadFromFile(Song.java:827)
    ... 1 more
Caused by: java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "java.util.Map$Entry.getValue()" is null
    at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:96)
    at com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:478)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:58)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)
    at com.thoughtworks.xstream.converters.reflection.SerializableConverter$2.readFromStream(SerializableConverter.java:325)
    at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readObjectOverride(CustomObjectInputStream.java:123)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:505)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:472)
    at org.jjazz.chordleadsheet.api.item.ChordRenderingInfo$SerializationProxy.readObject(ChordRenderingInfo.java:503)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.thoughtworks.xstream.core.util.SerializationMembers.callReadObject(SerializationMembers.java:132)
    ... 47 more
jjazzboss commented 1 month ago

I tried loading an older song, saving created song and relad, no errors, I could not reproduce... Can you post the .sng file please ?

jjazzboss commented 1 month ago

It was a tricky one because the root cause exception in Xstream does not show up in the log.

I could reproduce the issue by removing some --add-opens/--add-exports options for the java command line. They are required by the Xstream library which uses reflection.

So make sure you use all the same args used in DemoApp/pom.xml. Test it using mvn exec:exec