The application that I am working on uses Redis and as fas as I know Redis tries to serialize every objects that are being stored in session.I have a below line in my code which is troubling me:-
httpServletRequest.getSession.setAttribute(some_key, someObjectFactory.someMethod(httpServletRequest);
I am getting below exception which is being thrown from the above line of code.
ava.io.IOException: java.lang.RuntimeException: Class org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper does not implement Serializable or externalizable
The "SomeObjectFactory" class looks like below, after I made it to implement Serializable
@Componendpublic class SomeObjectFactory implements Serializable {//ssvuid declarationprivate Object1 object1;private Object2 object2;@Autowiredpublic SomeObjectFactory(Object1 object1, Object2 object2) { this.object1 = object1; this.object2 = object2;}public SomeVOObject someMethod(HttpServletRequest request){ return new SomeVOObject(request , new SomeObjectMapper(object1, object2)}
I have made all the dependent objects implements Serializable and everything but still I am getting "does not implement Serializable or externalizable" exception. I doubt this is because the "SomeVOObject" has httpServletRequest also as it's first argument in the constructor and httpServletRequest cann't be Serialized.
Please advise if there is any solution already available or any approach to overcome this.