Context / Background:
A client connects through a web socket. The server saves the WebSocket session and several other identifiers on the card for later use. The server receives some data from the queue, which must be sent to the client via a web socket. Using the session from the card, I can send it to the client. So far so good.
All this works fine for a single node, but not with multiple nodes (no clustering is necessary), because the WebSocket session is not Serializable, therefore deliemma :( I was hoping to save the WebSocket session in the Postgresql database for later use, but I'm amazed at Serialization.
What I tried:
Someone else asked a similar question on a non-serializable websocket java ee session . I tried to create a wrapper around the Tomcat session and provide readObject writeObject, but unfortunately WsSession does not allow setting / reading state.
I tried using the https://github.com/EsotericSoftware/kryo library , but could not serialize my shell for WsSession.
My environment:
JDK 1.8.0_31, Tomcat 8.0.20, Spring 4.1.5.RELEASE, Debian Wheezy.
Thank you for your help.
Update:
when trying Serialize using Kryo, I get the following exception
com.esotericsoftware.kryo.KryoException: java.util.ConcurrentModificationException
Serialization trace:
classes (sun.misc.Launcher$AppClassLoader)
applicationClassLoader (org.apache.tomcat.websocket.WsSession)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:101) ~[kryo-3.0.1-SNAPSHOT.jar:?]
I also tried XStream http://x-stream.imtqy.com/ and it serializes in xml, however when de-serializing I get the following exception
message : Could not call java.security.CodeSource.readObject()
cause-exception : java.lang.RuntimeException
cause-message : null
class : java.security.CodeSource
required-type : java.security.CodeSource
converter-type : com.thoughtworks.xstream.converters.reflection.SerializableConverter
path : /org.apache.tomcat.websocket.WsSession/applicationClassLoader/parent/defaultDomain/codesource/java.security.CodeSource
line number : 30863
class[1] : java.security.ProtectionDomain
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : sun.misc.Launcher$ExtClassLoader
class[3] : sun.misc.Launcher$AppClassLoader
class[4] : org.apache.tomcat.websocket.WsSession
version : 1.4.8
1:
, websocket .