You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Frédéric Ledent <fr...@market-ip.com> on 2004/06/24 15:50:23 UTC

Session exists, but doesn't contain an engine

Hi all,


I have more details about the problem/bug about the new Visit object created
for no good reason.

I explain the problem again:
I’m currently using PageValidateListener and its pageValidate(PageEvent
event) to Secure my application, visit object and user id are checked at
each page request.
Sometimes after the first login, when I request another page, I'm rejected
to Home page. It seems that the engine instance is not the same between the
two requests.

I logged this:"
ApplicationServlet - doService
ApplicationServlet - Using pooled engine
BaseEngine@ea6f34[name=Test,dirty=true,locale=fr_BE,stateful=false,visit=<nu
ll>,activePageNames=<null>] (from locale fr_BE).
ApplicationServlet - Returning
BaseEngine@ea6f34[name=Test,dirty=true,locale=fr_BE,stateful=false,visit=<nu
ll>,activePageNames=<null>] to pool.
ApplicationServlet - Using pooled engine
BaseEngine@ea6f34[name=Test,dirty=true,locale=fr_BE,stateful=false,visit=<nu
ll>,activePageNames=<null>] (from locale fr_BE).
ApplicationServlet - doService
ApplicationServlet - Session exists, but doesn't contain an engine.
ApplicationServlet - Creating engine from class BaseEngine
ApplicationServlet - Created engine BaseEngine@f4a9a3[name=<Unknown
specification>,dirty=false,locale=<null>,stateful=false,visit=<null>
,activePageNames=<null>]
ApplicationServlet - Storing
BaseEngine@ea6f34[name=Test,dirty=true,locale=fr_BE,stateful=true,visit=
Visit@ad3f16,activePageNames=[pageTest]] into session
ApplicationServlet - Storing
BaseEngine@f4a9a3[name=Test,dirty=true,locale=fr_BE,stateful=false,visit=<nu
ll>,activePageNames=<null>] into session
ApplicationServlet - doService
ApplicationServlet - Retrieved
BaseEngine@f4a9a3[name=Test,dirty=false,locale=fr_BE,stateful=false,visit=<n
ull>,activePageNames=<null>] from session.
ApplicationServlet - doService"

The problem comes from here: "Session exists, but doesn't contain an
engine".
The system try to find the engine in the session before the storing of it.
So it creates a new Instance of BaseEngine during the good one is stored in
the session and then this instance (activePageNames=<null>]) is stored over
the good one (activePageNames=[pageTest]).

I don’t know if this is a bug or something but I'm currently avoiding this
problem with this (kind of) solution:
I'm overriding the AbstractEngine.getVisit(IRequestCycle cycle) like that: 

    public Object getVisit(IRequestCycle cycle)
    {
		if (_visit == null && cycle != null)
		{        	        	    	
			_visit =
cycle.getRequestContext().getRequest().getSession().getAttribute("Visit");
			if (_visit != null) {
				LOG.debug("Visit object retrieved from
session");				
			}			
		}
        if (_visit == null && cycle != null)
        {        	        	
        	if (_visit == null) {
				_visit = createVisit(cycle);
        	}

            // Now that a visit object exists, we need to force the creation
            // of a HttpSession.

            cycle.getRequestContext().createSession();

            setStateful();
        }

        if (_visit != null)
            markDirty();

		if
(cycle.getRequestContext().getRequest().getSession().getAttribute("Visit")
== null) {			
	
cycle.getRequestContext().getRequest().getSession().setAttribute("Visit",_vi
sit);	
			LOG.debug("Visit object stored in session");

		}		
        return _visit;
    }


Thanks a lot for help and/or comments.

Regards


Fred



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org