-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unreadable session after serialization #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@YLombardi Thank you for your question :) You cannot really read bytes in Redis until they are converted and the template.setHashValueSerializer(new LdapFailAwareRedisObjectSerializer()); to use something that writes in a human readable format (i.e. JSON). Does this help? |
@rwinch Thank you for your quick answer. I already try to change the HashValueSerializer to use a default serializer (GenericJackson2JsonRedisSerializer and JacksonJsonRedisSerializer). It store a readable data in the Redis database but when I try to access the application, it create some SerializationException and the application crash :
|
It sounds as though you need to handle non-default constructor on third party classes. For example http://stackoverflow.com/questions/11838039/jackson-3rd-party-class-with-no-default-constructor |
Because of this problem I can't share spring app session with other non spring apps. |
@rwinch I tried out this:
but I am still getting not readable value:
|
@Lev09 Are you certain that is on a new session? Where is the value at (is it a hash key, value, etc). What version of Spring Session are you on? |
@rwinch I am using spring security with spring session 1.0.2.RELEASE, so when I log in, the session is created and saved to Redis automatically. When I am trying to read the "creationTime" session attribute with |
I got json serialized session persitence to work using @Bean
public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
XStreamMarshaller xStreamMarshaller = new XStreamMarshaller();
xStreamMarshaller.setStreamDriver(new JettisonMappedXmlDriver());
return new OxmSerializer(xStreamMarshaller, xStreamMarshaller);
} And redis gives me
But, unfortunately jettison is not really maintained anymore. |
This setup works with basic http authentication. @Bean
public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new SimpleModule().addSerializer(new NullValueSerializer(null)));
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
mapper.registerModules(SecurityJackson2Modules.getModules(this.getClass().getClassLoader()));
return new GenericJackson2JsonRedisSerializer(mapper);
} But, i 've problems with |
I use Spring session with a Redis repository.
I also use the same Redis to store cache data.
It works fine but I the session attributes that are storred in Redis are unreadable.
When I try to read the content of the repository, I see this :
http://img11.hostingpics.net/pics/492480redisexpiration.png
Here is my configuration classes :
I use a custom serializer because I had an issue with the serialization of ldap information (http://stackoverflow.com/questions/32751094/spring-boot-with-session-redis-serialization-error-with-bad-active-directory-lda).
Any idea why I can't read content of the redis database ?
I think this is a serialization issue but I don't find any solution.
The text was updated successfully, but these errors were encountered: