This is extremely odd - I was able to serialize SimpleSessions across a cluster in my last project without problems.
Strangely enough, there is already a SimpleSessionTest class to test exactly this - but for some reason the serialize/deserialize test is commented out and I'm not sure why. Can you please open a Jira? If you want to try to get it to work the test is in the core module, in src/test/java/org/apache/shiro/session/mgt/SimpleSessionTest.java If you find an issue and can contribute back a patch, we'd be grateful! Les On Wed, Sep 15, 2010 at 9:48 PM, Mike K <[email protected]> wrote: > > Anyone experience issues serializing SimpleSession ? > The following works for String but fails for SimpleSession. The reason I am > converting to bytes is to use ZooKeeper for clustering, but I can't get over > not being able to rehydrate a SimpleSession. > private byte[] toBytes(Object value) { > try { > ByteArrayOutputStream baos = new > ByteArrayOutputStream() ; > ObjectOutputStream oos = new ObjectOutputStream(baos); > oos.writeObject(value); > oos.flush(); > oos.close(); > // Get the bytes of the serialized object > byte[] buf = baos.toByteArray(); > return buf; > } catch (IOException io) { > throw new CacheException(io); > } > } > > //@SuppressWarnings("unchecked") > private Object fromBytes(byte[] bytes) { > try { > ObjectInputStream ois = new ObjectInputStream(new > ByteArrayInputStream(bytes)); > Object value = ois.readObject(); > ois.close(); > return value; > } catch (ClassNotFoundException e) { > throw new CacheException(e); > } catch (IOException e) { > throw new CacheException(e); > } catch (ClassCastException e) { > throw new CacheException(e); > } > } > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/serialization-problem-with-SimpleSession-tp5537015p5537015.html > Sent from the Shiro User mailing list archive at Nabble.com. >
