Getting extra sessions created? App losing track of which session it is? Getting "Backtracked Too Far" errors with no apparent cause? Your first stop should be to take a close look at the requests that the application is receiving.
Add this to your Application.java and take a close look at the requests that come in and when.
Still getting session creation that you can't figure out? Try adding this to Session.java:
One other thing to look for is accessing a session from a component that isn't properly registered to a session. Calling session() on a component will always return a Session object. If a session doesn't exist, a new one will lazily be created. There are cases where you might think a session should be related to your component, and yet one is not. Calling session() will lazily create a new session, even when you don't want one – which may not be correctly tracked by your Application. This will cause your application to hang when attempting to do a graceful shutdown. Take a look at the method Component.hasSession(). Check to see that you have Session before assuming you really do. This will help keep this runaway sessions in check.
Similarly, WOContext objects also lazily create new sessions. Check Context.hasSession() prior to accidentally creating new sessions.