Note: this won't make any sense unless you're very familiar with Java, Spring AOP, and Tomcat.
The problem is that beans marked @Configurable are not injected when deserialized by Tomcat SESSIONS.ser.
I noticed this behavior on a Struts 1.2.9 based (legacy) application with Spring 2.5.4, spring-tomcat-weaver-2.5.4, Tomcat 6.0.14.
Code:
public class MyForm implements Serializable {
private Foo myFoo; // getters and setters
}
public class Foo imlements Serializable {
private Bar myBar; // getters setters
}
@Configurable("barTemplate")
public class Bar implements Serializable {
@Autowired(required=true)
private transient SessionFactory hello;
// other transient dependencies ...
}
The XML configures Bar as a prototype bean.
The correct context:spring-configured and context:load-time-weaver settings are applied, etc (since it works on a cold start of Tomcat).
Everything works fine when starting for the first time. However, restarting Tomcat causes to write SESSIONS.ser and upon rebooting, to deserialize MyForm, which it does. However, none of the dependencies in Bar are set!
But if I shutdown Tomcat, delete the SESSIONS.ser file, and reboot, then everything will work.
Weird.
Any advice greatly appreciated.