XStream
  1. XStream
  2. XSTR-554

XStream fromXml of groovy objects fails within a syncronsized map

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.3
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      JDK 1.6.0_11 on Windows XP

      Description

      re-persisting an object with a package level variable after its been loaded by xstream fails with the following exception:

      ---- Debugging information ----
      message             : Could not call
      java.util.Collections$SynchronizedMap.writeObject() 
      cause-message       : null 
      cause-exception     : java.lang.reflect.InvocationTargetException 
      ------------------------------- org.groovymud.shell.telnetd.MudShell 
      com.thoughtworks.xstream.converters.ConversionException: Could not call
      java.util.Collections$SynchronizedMap.writeObject()
      ---- Debugging information ----
      message             : Could not call
      java.util.Collections$SynchronizedMap.writeObject() 
      cause-message       : null 
      cause-exception     : java.lang.reflect.InvocationTargetException 
      -------------------------------
      	at
      com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteObject(SerializationMethodInvoker.java:92)
      	at
      com.thoughtworks.xstream.converters.reflection.SerializableConverter.marshal(SerializableConverter.java:186)
      	at
      com.thoughtworks.xstream.core.ReferenceByXPathMarshaller.convertAnother(ReferenceByXPathMarshaller.java:36)
      	at
      com.thoughtworks.xstream.converters.reflection.ReflectionConverter$1.writeField(ReflectionConverter.java:81)
      	at
      com.thoughtworks.xstream.converters.reflection.ReflectionConverter$1.visit(ReflectionConverter.java:59)
      	at
      com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:108)
      	at
      com.thoughtworks.xstream.converters.reflection.ReflectionConverter.marshal(ReflectionConverter.java:44)
      	at
      com.thoughtworks.xstream.core.ReferenceByXPathMarshaller.convertAnother(ReferenceByXPathMarshaller.java:36)
      	at
      com.thoughtworks.xstream.converters.reflection.ReflectionConverter$1.writeField(ReflectionConverter.java:81)
      	at
      com.thoughtworks.xstream.converters.reflection.ReflectionConverter$1.visit(ReflectionConverter.java:59)
      	at
      com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:108)
      	at
      com.thoughtworks.xstream.converters.reflection.ReflectionConverter.marshal(ReflectionConverter.java:44)
      	at
      com.thoughtworks.xstream.core.ReferenceByXPathMarshaller.convertAnother(ReferenceByXPathMarshaller.java:36)
      	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:46)
      	at
      com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.marshal(ReferenceByXPathMarshallingStrategy.java:17)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:476)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:466)
      	at com.thoughtworks.xstream.XStream.toXML(XStream.java:458)
      	at
      org.groovymud.object.registry.MudObjectAttendant.savePlayerData(MudObjectAttendant.java:260)
      	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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
      	at
      org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:766)
      	at
      org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:754)
      	at
      org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
      	at commands.player.save.run(save.groovy:13)
      	at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:386)
      	at
      org.groovymud.shell.command.CommandInterpreter.doCommand(CommandInterpreter.java:165)
      	at
      org.groovymud.shell.command.CommandInterpreter$1.run(CommandInterpreter.java:113)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at javax.security.auth.Subject.doAsPrivileged(Subject.java:454)
      	at
      org.groovymud.shell.command.CommandInterpreter.doShellCommand(CommandInterpreter.java:104)
      	at org.groovymud.shell.telnetd.MudShell.handleRequest(MudShell.java:58)
      	at org.groovymud.shell.telnetd.MudShell.run(MudShell.java:32)
      	at net.wimpi.telnetd.net.Connection.run(Connection.java:119)
      Caused by: java.lang.reflect.InvocationTargetException
      	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.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteObject(SerializationMethodInvoker.java:88)
      	... 39 more
      Caused by: com.thoughtworks.xstream.converters.ConversionException: Could
      not call java.util.Collections$SynchronizedMap.writeObject()
      

      the groovy object is in a synchronized map and has a package level variable which, in another exception I do not have to hand, seems to be the cause of the problem.

      Reproduce (using Java, not Groovy - you should load the groovy object using the GroovyScriptEngine):

      1. persist an object using XStream with a synchronized map that contains a groovy object with a package protected variable in it
      2. load that object using fromXML with the same XStream object
      3. try to persist that object using the same XStream object

      Interestingly, if you use a different XStream object, as suggested at

      http://www.bobsgear.com/display/bobsgear/Could+not+get+field+class+error+with+xstream

      ... this works fine. I have worked round this for now with that exact solution.

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Matthew Corby-Eaglen
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: