Sessions behaving strange in 6.0.0

Hi

Today I wanted to migrate my application from 5.3.0 to 6.0.0. With the migration guide this was no big hassle.

But when developing and testing afterwards, I noticed some strange behavior.
When I changed some Java files, built the project and deployed it to Tomcat, still the old code was executed. When using 5.3.0, this was normally not a problem, because after clicking on a few widgets, I was informed with an error dialog that I must restart the dialog - and after I have done that, I saw the changes.

However with 6.0.0, this seems never to happen. More strange, even after stopping and restarting Tomcat the session seemed to survive (I checked that Tomcat was down and got server-not-found error in the browser).

To make sure that I did not change any other thing, I recreated the old 5.3.0 version and put a logging statement in Application.init() - and yes it could confirm my observations. With 6.0.0 it was possible that even after a restart of Tomcat the old session was reused and Application.init() not called.

Do you have any idea what is going on here and what change made may cause this issue?

Regards,
Thomas

Actually it is a feature, not an issue :)

See this discussion on how to prevent sessions from serializing:

http://vaadin.com/forum/-/message_boards/message/35237#_19_message_36623

As an old-school Vaadin and Tomcat user I noticed the same annoyance. A simple solution for me was to use the
restartApplication
parameter in URL to help quick code refreshes. Like:
http://localhost:8080/MyApp/?restartApplication
. This way a browser reload causes a new application init automatically.

Joonas,

Great to here that it is a feature and not an issue… After encountering the problems yesterday, I even read the release notes but I did not see anything special.

After reading again, I now detected “Vaadin applications are now serializable”.

Can you elaborate further what this means? When is the session serialized? Is there some kind of documentation - I looked at the book of Vaadin but did not find anything.

I also read the thread you mentioned. There it is written that to turn the feature off, you have to make a change in Tomcat’s conf/context.xml. In my hosting environment, I am not allowed to make changes there. So is there another way for configuration?

Thanks for your help
Thomas

As your application (UI) lives in HttpSession, serializing the application enables you to transfer application states from one server to another or to be able to restart the server without closing the application. Actually this is exactly what happens in your case.

This is controlled by the server. Tomcat for example serializes when the server is shut down. Google App Engine serializes for each Ajax request (which is really annoying and stupid in my opinion).

To control serialization you must configure your Java Server. For example, this is used to disable serialization on server shutdown in Tomcat conf/context.xml:


<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

Good question. Anyone know answer for this?

I believe you can do this also by creating your own context.xml file under the META-INF directory of your web application (in an Eclipse project this directory would be found under the WebContent directory). This way you don’t have to touch the “global” conf/context.xml.

See also
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
for more information.

I can confirm it, this is the best method to do it. Just copy the context.xml with properly uncommenting that lines to WebContent/WEB-INF and be happy. Thank you for the tip!

Now I don’t get exceptions caused by Hibernate engine lack of serialization any more. This way the setting is just for the project, not the entire server.

Another good reason to do it this way is, with Eclipse JEE controlling the Tomcat server, it works now. Otherwise, it doesn’t work unless when launching the server directly. I think it doesn’t read the default context.xml (neither other config files) when loading Tomcat within Eclipse.