Originally posted by Erap Estrada: Hi. I have objects that I would like to load in session upon tomcat restart.
How would I do that?
Thanks in advance!
You can't do this, exactly, since when the container restarts, there aren't sessions in existence ( Someone please correct me if I'm wrong ). You'll have to wait for the client to participate in a session first.
You could use the sessionCreated() event of the HttpSessionListener to populate your session with appropriate data.
You want to load the array of beans when the session is created or when Tomcat starts/restarts?
When Tomcat initially starts, there won't be any sessions. When it restarts, if your code allows it, it will deserialize any sessions that existed when it was shut down; but those sessions had to already exist.
If you can explain why you want to do this, maybe someone can suggest a better alternative (or, if we're misunderstanding you, maybe it would make things more clear for us).