Oops - never mind - the serializeAndDeserialize method in that class is in fact used in the 'serializeHost' test case. It appears that serialization is working - at least for that particular test.
This leads me to believe that if serialization fails, it is because of the state of one of SimpleSession's attributes. In your test, what are your attributes set to? Then I can add a new test in the SimpleSessionTest class to verify. Les On Wed, Sep 15, 2010 at 9:56 PM, Les Hazlewood <[email protected]> wrote: > 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. >> >
