You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ivano Luberti <lu...@archicoop.it> on 2014/11/13 15:16:03 UTC

session invalidate in tapestry

Hi all, I have a question about session handling in Tapestry5.
I have a

@SessionState
    protected User user;

that works as expected

I wanted to perform some cleanup when calling a logout link: the action
link listener is made as this:

    public Object onActionFromLink() {
   
     
        requestGlobals.getHTTPServletRequest().getSession().invalidate();
       
       
        return Index.class;
     
    }

I don't know if this is important (I guess not) but the method is in a
component and not direclty in a page (so that I can render the link only
in protected pages )

To centralize the cleanup that could happen both on logout action and on
session timeout I have implemented the User with the  HttpSessionListener.

The problem is that after the invalidate() call the method

public void sessionDestroyed(HttpSessionEvent se) {

is called as intended but the User object is empty as it was just
instantiated and in fact debugging I can see that is a different
instance from the one created when the session was started.

I can certainly find other ways (a RequestFilter?) but I would like to
understand what is going on.

TIA


-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================



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


Re: session invalidate in tapestry

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 14 Nov 2014 18:15:12 -0200, Ivano Luberti <lu...@archicoop.it>  
wrote:

> Oh God!
> Yes , I messed up with interfaces: too much time using PHP

Hehehe. Actually, even without PHP messing up with your brain, it's easy  
to mistake one of the interfaces for the other . . .

> Thanks Thiago

:D

> Il 14/11/2014 20:47, Thiago H de Paula Figueiredo ha scritto:
>> On Fri, 14 Nov 2014 15:27:51 -0200, Ivano Luberti
>> <lu...@archicoop.it> wrote:
>>
>>> So B is created in the first page but not bound to the session while
>>> some way is visible across pages
>>> While A is created at server start-up (why?) but is not visible in
>>> the page.
>>> If from web.xml  I remove
>>>
>>> <listener>
>>> <listener-class>it.archicoop.met.obliterazione.beans.User</listener-class>
>>>
>>> </listener>
>>
>> If you declare your User class like this, for the listening itself,
>> the servlet container will create a single User instance and invoke
>> its methods. This is completely unrelated to Tapestry's @SessionState.
>> Why are you doing that? Using the same class for this listener *and*
>> as an @SessionState field makes no sense at all, at least at first.
>>
>> Shouldn't your User class implement HttpSessionBindingListener instead?
>>
>


-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: session invalidate in tapestry

Posted by Ivano Luberti <lu...@archicoop.it>.
Oh God!
Yes , I messed up with interfaces: too much time using PHP

Thanks Thiago
 
Il 14/11/2014 20:47, Thiago H de Paula Figueiredo ha scritto:
> On Fri, 14 Nov 2014 15:27:51 -0200, Ivano Luberti
> <lu...@archicoop.it> wrote:
>
>> So B is created in the first page but not bound to the session while
>> some way is visible across pages
>> While A is created at server start-up (why?) but is not visible in
>> the page.
>> If from web.xml  I remove
>>
>> <listener>
>> <listener-class>it.archicoop.met.obliterazione.beans.User</listener-class>
>>
>> </listener>
>
> If you declare your User class like this, for the listening itself,
> the servlet container will create a single User instance and invoke
> its methods. This is completely unrelated to Tapestry's @SessionState.
> Why are you doing that? Using the same class for this listener *and*
> as an @SessionState field makes no sense at all, at least at first.
>
> Shouldn't your User class implement HttpSessionBindingListener instead?
>

-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================


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


Re: session invalidate in tapestry

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 14 Nov 2014 15:27:51 -0200, Ivano Luberti <lu...@archicoop.it>  
wrote:

> So B is created in the first page but not bound to the session while
> some way is visible across pages
> While A is created at server start-up (why?) but is not visible in the  
> page.
> If from web.xml  I remove
>
> <listener>
> <listener-class>it.archicoop.met.obliterazione.beans.User</listener-class>
> </listener>

If you declare your User class like this, for the listening itself, the  
servlet container will create a single User instance and invoke its  
methods. This is completely unrelated to Tapestry's @SessionState. Why are  
you doing that? Using the same class for this listener *and* as an  
@SessionState field makes no sense at all, at least at first.

Shouldn't your User class implement HttpSessionBindingListener instead?

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: session invalidate in tapestry

Posted by Ivano Luberti <lu...@archicoop.it>.

Il 14/11/2014 13:13, Thiago H de Paula Figueiredo ha scritto:
> On Fri, 14 Nov 2014 09:25:47 -0200, Ivano Luberti
> <lu...@archicoop.it> wrote:
>
>> Hi
>
> Hi!
>
>> When I call the Index page in the browser  onPrepare is called
>
> What's your onPrepare() method? You didn't post it here. By the way,
> you could print a stack trace inside the User constructor to know
> exactly which method is instantiating it.
>

Here is the code: is not onPrepare but setupRender , sorry, I had
changed it from onPrepare but the result has not changed, anyway


    @Log
    public void setupRender(){
       
       
        try {
           
            Loginform lf=
user.getWsclient().getLoginForm(requestGlobal.getHTTPServletRequest().getRemoteAddr());
           
            monumenti=lf.getMonumenti();
           
            postazioni=lf.getPostazioni();
           
            idMonumentoSelezionato=lf.getIdMonumentoSelezionato();
           
           
user.setIp(requestGlobal.getHTTPServletRequest().getRemoteAddr());
           
        } catch (Exception e) {
       
            logger.debug(e.getMessage());
        }

       
    }


Here are the stack traces produced by the constuctor calls and
sessionCreated and session destroyed methods
You can see that

1) an instance A is created when tomcat starts up

2) instance A is bounded to the session when first page is visited

3) when first page is visited also instance B is created but not bound
to any session

4) on logout instance A id unbound from session

5) on redirection to Index instance B is discarded and instance C is
created but not attached to the session

So B is created in the first page but not bound to the session while
some way is visible across pages
While A is created at server start-up (why?) but is not visible in the page.
If from web.xml  I remove

<listener>
       
<listener-class>it.archicoop.met.obliterazione.beans.User</listener-class>
</listener>

of course A is not created anymore but neither are called sessionCreated
and sessionDestroy
While B keep on behaving as described

When I start the application an instance is created and printing a stack
trace produces:


I'm it.archicoop.met.obliterazione.beans.User@4e1a70b8 and I'm created here:
it.archicoop.met.obliterazione.beans.User,<init>,34
sun.reflect.NativeConstructorAccessorImpl,newInstance0,-2
sun.reflect.NativeConstructorAccessorImpl,newInstance,39
sun.reflect.DelegatingConstructorAccessorImpl,newInstance,27
java.lang.reflect.Constructor,newInstance,513
java.lang.Class,newInstance0,357
java.lang.Class,newInstance,310
org.apache.catalina.core.StandardContext,listenerStart,4150
org.apache.catalina.core.StandardContext,start,4705
org.apache.catalina.core.ContainerBase,start,1057
org.apache.catalina.core.StandardHost,start,840
org.apache.catalina.core.ContainerBase,start,1057
org.apache.catalina.core.StandardEngine,start,463
org.apache.catalina.core.StandardService,start,525
org.apache.catalina.core.StandardServer,start,754
org.apache.catalina.startup.Catalina,start,595
sun.reflect.NativeMethodAccessorImpl,invoke0,-2
sun.reflect.NativeMethodAccessorImpl,invoke,39
sun.reflect.DelegatingMethodAccessorImpl,invoke,25
java.lang.reflect.Method,invoke,597
org.apache.catalina.startup.Bootstrap,start,289
org.apache.catalina.startup.Bootstrap,main,414



When I load the Index Page, first is invoked sessionCreated()


[DEBUG] pages.Index [ENTER] setupRender()
I'm bounded and I'm: it.archicoop.met.obliterazione.beans.User@4e1a70b8
in session 4CEC6E6D283C89FAEBCBEFF0D578E0DE
it.archicoop.met.obliterazione.beans.User,sessionCreated,104
org.apache.catalina.session.StandardSession,tellNew,392
org.apache.catalina.session.StandardSession,setId,363
org.apache.catalina.session.StandardSession,setId,345
org.apache.catalina.session.ManagerBase,createSession,906
org.apache.catalina.session.StandardManager,createSession,292
org.apache.catalina.connector.Request,doGetSession,2448
org.apache.catalina.connector.Request,getSession,2157
org.apache.catalina.connector.RequestFacade,getSession,833
$HttpServletRequest_18d69c7688d1,getSession,-1
$HttpServletRequest_18d69c7688cf,getSession,-1
org.apache.tapestry5.internal.services.TapestrySessionFactoryImpl,getSession,44
$TapestrySessionFactory_18d69c7688cc,getSession,-1
org.apache.tapestry5.internal.services.RequestImpl,getSession,115
$Request_18d69c7688f3,getSession,-1
$Request_18d69c7688bb,getSession,-1
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy,getSession,38
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy,getOrCreate,49
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy,get,44
$ApplicationStatePersistenceStrategy_18d69c768994,get,-1
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter,getOrCreate,50
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl,get,133
$ApplicationStateManager_18d69c7688fa,get,-1
org.apache.tapestry5.internal.transform.ApplicationStateWorker$1,get,75
it.archicoop.met.obliterazione.base.BasePage,conduit_get_user,-1
it.archicoop.met.obliterazione.pages.Index,advised$setupRender_18d69c76890a,69
it.archicoop.met.obliterazione.pages.Index$Invocation_setupRender_18d69c768909,proceedToAdvisedMethod,-1
org.apache.tapestry5.internal.plastic.AbstractMethodInvocation,proceed,84
org.apache.tapestry5.ioc.internal.services.LoggingAdvice,advise,45
org.apache.tapestry5.internal.plastic.AbstractMethodInvocation,proceed,86
it.archicoop.met.obliterazione.pages.Index,setupRender,-1
it.archicoop.met.obliterazione.pages.Index,setupRender,-1
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase,invokeComponent,179
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase,invoke,138
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase,render,186
org.apache.tapestry5.internal.services.RenderQueueImpl,run,72
org.apache.tapestry5.internal.services.PageRenderQueueImpl,render,124
$PageRenderQueue_18d69c76898d,render,-1
$PageRenderQueue_18d69c76898c,render,-1
org.apache.tapestry5.internal.services.MarkupRendererTerminator,renderMarkup,37
org.apache.tapestry5.services.TapestryModule$31,renderMarkup,1994
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$30,renderMarkup,1978
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$29,renderMarkup,1960
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$28,renderMarkup,1945
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$27,renderMarkup,1931
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$26,renderMarkup,1913
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$25,renderMarkup,1894
$MarkupRenderer_18d69c768990,renderMarkup,-1
$MarkupRenderer_18d69c76898b,renderMarkup,-1
org.apache.tapestry5.internal.services.PageMarkupRendererImpl,renderPageMarkup,47
$PageMarkupRenderer_18d69c768989,renderPageMarkup,-1
org.apache.tapestry5.internal.services.PageResponseRendererImpl,renderPageResponse,67
$PageResponseRenderer_18d69c768985,renderPageResponse,-1
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl,handle,64
org.apache.tapestry5.services.TapestryModule$38,handle,2222
$PageRenderRequestHandler_18d69c768987,handle,-1
$PageRenderRequestHandler_18d69c768910,handle,-1
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator,handlePageRender,48
org.apache.tapestry5.services.InitializeActivePageName,handlePageRender,47
$ComponentRequestHandler_18d69c768911,handlePageRender,-1
it.archicoop.met.obliterazione.services.PageProtectionFilter,handlePageRender,63
$ComponentRequestFilter_18d69c76890e,handlePageRender,-1
$ComponentRequestHandler_18d69c768911,handlePageRender,-1
$ComponentRequestHandler_18d69c7688da,handlePageRender,-1
org.apache.tapestry5.internal.services.PageRenderDispatcher,dispatch,45
$Dispatcher_18d69c7688dd,dispatch,-1
$Dispatcher_18d69c7688d7,dispatch,-1
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator,service,302
org.apache.tapestry5.internal.services.RequestErrorFilter,service,26
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.services.TapestryModule$3,service,902
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.services.TapestryModule$2,service,892
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.internal.services.StaticFilesFilter,service,90
$RequestHandler_18d69c7688d8,service,-1
it.archicoop.met.obliterazione.services.AppModule$1,service,121
$RequestFilter_18d69c7688d2,service,-1
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2,invoke,105
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2,invoke,95
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier,withRead,85
org.apache.tapestry5.internal.services.CheckForUpdatesFilter,service,119
$RequestHandler_18d69c7688d8,service,-1
$RequestHandler_18d69c7688cb,service,-1
org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator,service,253
org.apache.tapestry5.internal.gzip.GZipFilter,service,53
$HttpServletRequestHandler_18d69c7688cd,service,-1
org.apache.tapestry5.internal.services.IgnoredPathsFilter,service,62
$HttpServletRequestFilter_18d69c7688c9,service,-1
$HttpServletRequestHandler_18d69c7688cd,service,-1
org.apache.tapestry5.services.TapestryModule$1,service,852
$HttpServletRequestHandler_18d69c7688cd,service,-1
$HttpServletRequestHandler_18d69c7688c8,service,-1
org.apache.tapestry5.TapestryFilter,doFilter,171
org.apache.catalina.core.ApplicationFilterChain,internalDoFilter,235
org.apache.catalina.core.ApplicationFilterChain,doFilter,206
org.apache.catalina.core.StandardWrapperValve,invoke,233
org.apache.catalina.core.StandardContextValve,invoke,191
org.apache.catalina.core.StandardHostValve,invoke,127
org.apache.catalina.valves.ErrorReportValve,invoke,103
org.apache.catalina.core.StandardEngineValve,invoke,109
org.apache.catalina.connector.CoyoteAdapter,service,293
org.apache.coyote.http11.Http11Processor,process,861
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler,process,606
org.apache.tomcat.util.net.JIoEndpoint$Worker,run,489
java.lang.Thread,run,662

Then the constructor (but of another instance)

I'm it.archicoop.met.obliterazione.beans.User@1f5ebb08 and I'm created here:
it.archicoop.met.obliterazione.beans.User,<init>,34
sun.reflect.NativeConstructorAccessorImpl,newInstance0,-2
sun.reflect.NativeConstructorAccessorImpl,newInstance,39
sun.reflect.DelegatingConstructorAccessorImpl,newInstance,27
java.lang.reflect.Constructor,newInstance,513
org.apache.tapestry5.ioc.internal.util.ConstructorInvoker,invoke,48
org.apache.tapestry5.ioc.internal.util.LoggingInvokableWrapper,invoke,42
org.apache.tapestry5.ioc.internal.OperationTrackerImpl,invoke,74
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker,invoke,87
org.apache.tapestry5.ioc.internal.RegistryImpl,invoke,1124
org.apache.tapestry5.ioc.internal.util.ConstructionPlan,createObject,60
org.apache.tapestry5.ioc.internal.ConstructorServiceCreator,createObject,61
org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$4,invoke,160
org.apache.tapestry5.ioc.internal.OperationTrackerImpl,invoke,74
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker,invoke,87
org.apache.tapestry5.ioc.internal.RegistryImpl,invoke,1124
org.apache.tapestry5.ioc.internal.ServiceResourcesImpl,autobuild,146
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$1,create,104
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy,getOrCreate,57
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy,get,44
$ApplicationStatePersistenceStrategy_18d69c768994,get,-1
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter,getOrCreate,50
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl,get,133
$ApplicationStateManager_18d69c7688fa,get,-1
org.apache.tapestry5.internal.transform.ApplicationStateWorker$1,get,75
it.archicoop.met.obliterazione.base.BasePage,conduit_get_user,-1
it.archicoop.met.obliterazione.pages.Index,advised$setupRender_18d69c76890a,69
it.archicoop.met.obliterazione.pages.Index$Invocation_setupRender_18d69c768909,proceedToAdvisedMethod,-1
org.apache.tapestry5.internal.plastic.AbstractMethodInvocation,proceed,84
org.apache.tapestry5.ioc.internal.services.LoggingAdvice,advise,45
org.apache.tapestry5.internal.plastic.AbstractMethodInvocation,proceed,86
it.archicoop.met.obliterazione.pages.Index,setupRender,-1
it.archicoop.met.obliterazione.pages.Index,setupRender,-1
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase,invokeComponent,179
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase,invoke,138
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase,render,186
org.apache.tapestry5.internal.services.RenderQueueImpl,run,72
org.apache.tapestry5.internal.services.PageRenderQueueImpl,render,124
$PageRenderQueue_18d69c76898d,render,-1
$PageRenderQueue_18d69c76898c,render,-1
org.apache.tapestry5.internal.services.MarkupRendererTerminator,renderMarkup,37
org.apache.tapestry5.services.TapestryModule$31,renderMarkup,1994
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$30,renderMarkup,1978
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$29,renderMarkup,1960
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$28,renderMarkup,1945
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$27,renderMarkup,1931
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$26,renderMarkup,1913
$MarkupRenderer_18d69c768990,renderMarkup,-1
org.apache.tapestry5.services.TapestryModule$25,renderMarkup,1894
$MarkupRenderer_18d69c768990,renderMarkup,-1
$MarkupRenderer_18d69c76898b,renderMarkup,-1
org.apache.tapestry5.internal.services.PageMarkupRendererImpl,renderPageMarkup,47
$PageMarkupRenderer_18d69c768989,renderPageMarkup,-1
org.apache.tapestry5.internal.services.PageResponseRendererImpl,renderPageResponse,67
$PageResponseRenderer_18d69c768985,renderPageResponse,-1
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl,handle,64
org.apache.tapestry5.services.TapestryModule$38,handle,2222
$PageRenderRequestHandler_18d69c768987,handle,-1
$PageRenderRequestHandler_18d69c768910,handle,-1
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator,handlePageRender,48
org.apache.tapestry5.services.InitializeActivePageName,handlePageRender,47
$ComponentRequestHandler_18d69c768911,handlePageRender,-1
it.archicoop.met.obliterazione.services.PageProtectionFilter,handlePageRender,63
$ComponentRequestFilter_18d69c76890e,handlePageRender,-1
$ComponentRequestHandler_18d69c768911,handlePageRender,-1
$ComponentRequestHandler_18d69c7688da,handlePageRender,-1
org.apache.tapestry5.internal.services.PageRenderDispatcher,dispatch,45
$Dispatcher_18d69c7688dd,dispatch,-1
$Dispatcher_18d69c7688d7,dispatch,-1
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator,service,302
org.apache.tapestry5.internal.services.RequestErrorFilter,service,26
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.services.TapestryModule$3,service,902
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.services.TapestryModule$2,service,892
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.internal.services.StaticFilesFilter,service,90
$RequestHandler_18d69c7688d8,service,-1
it.archicoop.met.obliterazione.services.AppModule$1,service,121
$RequestFilter_18d69c7688d2,service,-1
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2,invoke,105
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2,invoke,95
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier,withRead,85
org.apache.tapestry5.internal.services.CheckForUpdatesFilter,service,119
$RequestHandler_18d69c7688d8,service,-1
$RequestHandler_18d69c7688cb,service,-1
org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator,service,253
org.apache.tapestry5.internal.gzip.GZipFilter,service,53
$HttpServletRequestHandler_18d69c7688cd,service,-1
org.apache.tapestry5.internal.services.IgnoredPathsFilter,service,62
$HttpServletRequestFilter_18d69c7688c9,service,-1
$HttpServletRequestHandler_18d69c7688cd,service,-1
org.apache.tapestry5.services.TapestryModule$1,service,852
$HttpServletRequestHandler_18d69c7688cd,service,-1
$HttpServletRequestHandler_18d69c7688c8,service,-1
org.apache.tapestry5.TapestryFilter,doFilter,171
org.apache.catalina.core.ApplicationFilterChain,internalDoFilter,235
org.apache.catalina.core.ApplicationFilterChain,doFilter,206
org.apache.catalina.core.StandardWrapperValve,invoke,233
org.apache.catalina.core.StandardContextValve,invoke,191
org.apache.catalina.core.StandardHostValve,invoke,127
org.apache.catalina.valves.ErrorReportValve,invoke,103
org.apache.catalina.core.StandardEngineValve,invoke,109
org.apache.catalina.connector.CoyoteAdapter,service,293
org.apache.coyote.http11.Http11Processor,process,861
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler,process,606
org.apache.tomcat.util.net.JIoEndpoint$Worker,run,489
java.lang.Thread,run,662

On session.invalidate the sessionDestroyedMethod is called.


I'm unbounded and I'm:
it.archicoop.met.obliterazione.beans.User@4e1a70b8 in session
4CEC6E6D283C89FAEBCBEFF0D578E0DE
it.archicoop.met.obliterazione.beans.User,sessionDestroyed,123
org.apache.catalina.session.StandardSession,expire,720
org.apache.catalina.session.StandardSession,expire,655
org.apache.catalina.session.StandardSession,invalidate,1169
org.apache.catalina.session.StandardSessionFacade,invalidate,150
org.apache.tapestry5.internal.services.SessionImpl,invalidate,86
it.archicoop.met.obliterazione.components.Logout,onActionFromLink,47
it.archicoop.met.obliterazione.components.Logout,dispatchComponentEvent,-1
org.apache.tapestry5.internal.structure.ComponentPageElementImpl,dispatchEvent,932
org.apache.tapestry5.internal.structure.ComponentPageElementImpl,processEventTriggering,1117
org.apache.tapestry5.internal.structure.ComponentPageElementImpl,access$3100,61
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5,invoke,1062
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5,invoke,1059
org.apache.tapestry5.ioc.internal.OperationTrackerImpl,invoke,74
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker,invoke,87
org.apache.tapestry5.ioc.internal.RegistryImpl,invoke,1124
org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl,invoke,146
org.apache.tapestry5.internal.structure.ComponentPageElementImpl,triggerContextEvent,1058
org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl,handle,81
org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter,handle,42
$ComponentEventRequestHandler_18d69c7689b5,handle,-1
org.apache.tapestry5.internal.services.AjaxFilter,handle,42
$ComponentEventRequestHandler_18d69c7689b5,handle,-1
org.apache.tapestry5.services.TapestryModule$41,handle,2476
$ComponentEventRequestHandler_18d69c7689b5,handle,-1
$ComponentEventRequestHandler_18d69c76890f,handle,-1
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator,handleComponentEvent,43
org.apache.tapestry5.services.InitializeActivePageName,handleComponentEvent,39
$ComponentRequestHandler_18d69c768911,handleComponentEvent,-1
it.archicoop.met.obliterazione.services.PageProtectionFilter,handleComponentEvent,76
$ComponentRequestFilter_18d69c76890e,handleComponentEvent,-1
$ComponentRequestHandler_18d69c768911,handleComponentEvent,-1
$ComponentRequestHandler_18d69c7688da,handleComponentEvent,-1
org.apache.tapestry5.internal.services.ComponentEventDispatcher,dispatch,46
$Dispatcher_18d69c7688dd,dispatch,-1
$Dispatcher_18d69c7688d7,dispatch,-1
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator,service,302
org.apache.tapestry5.internal.services.RequestErrorFilter,service,26
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.services.TapestryModule$3,service,902
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.services.TapestryModule$2,service,892
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.internal.services.StaticFilesFilter,service,90
$RequestHandler_18d69c7688d8,service,-1
it.archicoop.met.obliterazione.services.AppModule$1,service,121
$RequestFilter_18d69c7688d2,service,-1
$RequestHandler_18d69c7688d8,service,-1
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2,invoke,105
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2,invoke,95
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier,withRead,85
org.apache.tapestry5.internal.services.CheckForUpdatesFilter,service,119
$RequestHandler_18d69c7688d8,service,-1
$RequestHandler_18d69c7688cb,service,-1
org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator,service,253
org.apache.tapestry5.internal.gzip.GZipFilter,service,53
$HttpServletRequestHandler_18d69c7688cd,service,-1
org.apache.tapestry5.internal.services.IgnoredPathsFilter,service,62
$HttpServletRequestFilter_18d69c7688c9,service,-1
$HttpServletRequestHandler_18d69c7688cd,service,-1
org.apache.tapestry5.services.TapestryModule$1,service,852
$HttpServletRequestHandler_18d69c7688cd,service,-1
$HttpServletRequestHandler_18d69c7688c8,service,-1
org.apache.tapestry5.TapestryFilter,doFilter,171
org.apache.catalina.core.ApplicationFilterChain,internalDoFilter,235
org.apache.catalina.core.ApplicationFilterChain,doFilter,206
org.apache.catalina.core.StandardWrapperValve,invoke,233
org.apache.catalina.core.StandardContextValve,invoke,191
org.apache.catalina.core.StandardHostValve,invoke,127
org.apache.catalina.valves.ErrorReportValve,invoke,103
org.apache.catalina.core.StandardEngineValve,invoke,109
org.apache.catalina.connector.CoyoteAdapter,service,293
org.apache.coyote.http11.Http11Processor,process,861
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler,process,606
org.apache.tomcat.util.net.JIoEndpoint$Worker,run,489
java.lang.Thread,run,662






>> So it seems that the field of type User is not persisted between
>> different pages.
>
> Yes, it is. But I guess you're using the same field for @SessionState
> (storing authentication information) and login form. If yes, that's
> exactly what's messing up with your code.
>

not sure what you are saying: user is declared in the BasePage and used
in page the login form is another object declared in the Index page.



-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================



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


Re: session invalidate in tapestry

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 14 Nov 2014 09:25:47 -0200, Ivano Luberti <lu...@archicoop.it>  
wrote:

> Hi

Hi!

> When I call the Index page in the browser  onPrepare is called

What's your onPrepare() method? You didn't post it here. By the way, you  
could print a stack trace inside the User constructor to know exactly  
which method is instantiating it.

> So it seems that the field of type User is not persisted between
> different pages.

Yes, it is. But I guess you're using the same field for @SessionState  
(storing authentication information) and login form. If yes, that's  
exactly what's messing up with your code.

> As I sadi before: there are other ways to centrailize session boundign
> and unbounding

Not in Tapestry itself.

> but I wanted to know if in Tapestry I can use the
> HTTPSessionListener inteface for object persisted in the session

Yes, you can use it.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: session invalidate in tapestry

Posted by Ivano Luberti <lu...@archicoop.it>.
Hi

Il 13/11/2014 15:24, Thiago H de Paula Figueiredo ha scritto:
> On Thu, 13 Nov 2014 12:16:03 -0200, Ivano Luberti
> <lu...@archicoop.it> wrote:
>
>> Hi all, I have a question about session handling in Tapestry5.
>> I have a
>>
>> @SessionState
>>     protected User user;
>
> Shouldn't it be @SessionState(create = false) so user isn't
> instantiated automatically and is null until you set the field?
>

well in my case authentication and authorization is verified using
information that are popultaed only after login, so from my point of
view I had not advantage.
Anyway I followed you  on this.
But nothing changed.

>>
>> that works as expected
>>
>> I wanted to perform some cleanup when calling a logout link: the action
>> link listener is made as this:
>>
>>     public Object onActionFromLink() {
>>        requestGlobals.getHTTPServletRequest().getSession().invalidate();
>>        return Index.class;
>>    }
>
> You can (and should) @Inject Request. There's absolutely no reason in
> the last 5 years to use RequestGlobals to get the request object. You
> can also @Inject HttpServletRequest and HttpServletResponse directly
> if needed.
>
> @Inject
> private Request request;
>
> ...
>
> Session session = request.getSession(false);
> if (session != null) {
>     session.invalidate();
> }
>

I have done also this but to no avail.
So I try to explain what happens.

I have the following class

package it.archicoop.met.obliterazione.base;

import it.archicoop.met.obliterazione.beans.User;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

public class BasePage implements IPage{
       
    @SessionState(create=false)
    @Property
    protected User user;


User is defined as this:

package it.archicoop.met.obliterazione.beans;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;


public class User implements HttpSessionListener {
   
    public  User() {
    }
   
    public void sessionCreated(HttpSessionEvent se) {
               
        System.out.println("session started "+se.getSession().getId());
       
    }


    public void sessionDestroyed(HttpSessionEvent se) {

        System.out.println("session ended "+se.getSession().getId());
    
    }
}


Then I have

package it.archicoop.met.obliterazione.pages;
public class Index extends BasePage
{

and

package it.archicoop.met.obliterazione.pages;
public class BarCode extends BasePage
{


Logout link is implemented using  a component

package it.archicoop.met.obliterazione.components;

import it.archicoop.met.obliterazione.pages.Index;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.Session;


public class Logout
{
    @Inject
    private Request request;
   
    public Object onActionFromLink() {
   
     
        Session session = request.getSession(false);
        if (session != null) {
            session.invalidate();
        }
       
        return Index.class;
     
    }
   
}


public Object onActionFromLink() {
   
     
        Session session = request.getSession(false);
        if (session != null) {
            session.invalidate();
        }
       
       
        return Index.class;
     
    }


What happens


startup app

User constuctor called

it.archicoop.met.obliterazione.beans.User@2a801059

When I call the Index page in the browser  onPrepare is called

session created

it.archicoop.met.obliterazione.beans.User@2a801059

user field is null so constructor is called explicitly:

it.archicoop.met.obliterazione.beans.User@50862b70

login form submission

it.archicoop.met.obliterazione.beans.User@50862b70

Logout link

BarCode is the container of the Logout component

and user is null (WTF!?)

after session.invalidate is called

Session Destroyed

it.archicoop.met.obliterazione.beans.User@2a801059

Since I redirect to Index, again

onPrepare

user is initially

it.archicoop.met.obliterazione.beans.User@50862b70

then

user null

then recreated

it.archicoop.met.obliterazione.beans.User@4c057cc6

SessionCreated called

it.archicoop.met.obliterazione.beans.User@2a801059


So it seems that the field of type User is not persisted between
different pages.
And there is no relation between the user instances managed by the
servlet containt via SessionListener interface and the one in the pages

As I sadi before: there are other ways to centrailize session boundign
and unbounding but I wanted to know if in Tapestry I can use the
HTTPSessionListener inteface for object persisted in the session




-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================



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


Re: session invalidate in tapestry

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 13 Nov 2014 12:16:03 -0200, Ivano Luberti <lu...@archicoop.it>  
wrote:

> Hi all, I have a question about session handling in Tapestry5.
> I have a
>
> @SessionState
>     protected User user;

Shouldn't it be @SessionState(create = false) so user isn't instantiated  
automatically and is null until you set the field?

>
> that works as expected
>
> I wanted to perform some cleanup when calling a logout link: the action
> link listener is made as this:
>
>     public Object onActionFromLink() {
>        requestGlobals.getHTTPServletRequest().getSession().invalidate();
>        return Index.class;
>    }

You can (and should) @Inject Request. There's absolutely no reason in the  
last 5 years to use RequestGlobals to get the request object. You can also  
@Inject HttpServletRequest and HttpServletResponse directly if needed.

@Inject
private Request request;

...

Session session = request.getSession(false);
if (session != null) {
	session.invalidate();
}

> I don't know if this is important (I guess not) but the method is in a
> component and not direclty in a page (so that I can render the link only
> in protected pages )

No difference. Please change the @SessionState usage as I suggested and  
try again.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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