i am using spring 3 with JSF 2 and i replaced JSF managed beans with spring beans, by adding on top of bean:
@Component(\"mybean\")
@Scope(\"session\")
I had to use readObject()
+ static ApplicationContext
hack to solve the issue:
@Component
@Scope(value = SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class FlashMessages implements Serializable {
@Autowired
transient private SomeBean someBean;
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
// restore someBean field on deserialization
SpringUtils.getContext().getAutowireCapableBeanFactory().autowireBean(this);
}
}
@Component
public class SpringUtils implements ApplicationContextAware {
static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringUtils.applicationContext = applicationContext;
}
public static ApplicationContext getContext() {
return applicationContext;
}
}