You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Borut Bolčina <bo...@gmail.com> on 2009/03/10 01:07:09 UTC

@Meta("tapestry.persistence-strategy=client")

Hi,

I am trying to prevent session creation when using forms and in general. I
searched the mailing list but can not explain why the session is still being
created. I use 5.0.18.

Index.tml

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <body>
        <t:form t:id="myform">
            <t:label for="cardNumber"/>:
            <t:textfield t:id="cardNumber" value="cardNumber" size="20"/>
            <input type="submit" value="Submit"/>
        </t:form>
        <div>${cardNumber}</div>
    </body>
</html>

Index.java

@Meta("tapestry.persistence-strategy=client")
public class Index {

    @Property
    @Persist
    private String cardNumber;

}

Even when I remove the @Persist annotation from the cardNumber property, the
session is still being created. Until I remove the Form from the template.

I am monitoring session creation with a class in my same test project:

package bb.test.session;
import java.util.Date;

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

public class MyHttpSessionListener implements HttpSessionListener {
    public void sessionCreated(HttpSessionEvent se)
    {
        HttpSession session = se.getSession();
        System.out.print(getTime() + " (session) Created:");
        System.out.println("ID=" + session.getId() + " MaxInactiveInterval="
+ session.getMaxInactiveInterval());
    }
    public void sessionDestroyed(HttpSessionEvent se)
    {
        HttpSession session = se.getSession();
        // session has been invalidated and all session data (except Id)is
no longer available
        System.out.println(getTime() + " (session) Destroyed:ID=" +
session.getId());
    }
    private String getTime()
    {
        return new Date(System.currentTimeMillis()).toString();
    }

}

and with

    <listener>

<listener-class>bb.test.session.MyHttpSessionListener</listener-class>
    </listener>

in my web.xml.

Of course Firefox extension FireCookie is of help.

So, is this a bug?

Regards,
Borut

Re: @Meta("tapestry.persistence-strategy=client")

Posted by Borut Bolčina <bo...@gmail.com>.
Hi,

back to this...

Following your suggestion, this is the dump:

    at
bb.test.session.MyHttpSessionListener.sessionCreated(MyHttpSessionListener.java:15)
    at
org.mortbay.jetty.servlet.AbstractSessionManager.addSession(AbstractSessionManager.java:574)
    at
org.mortbay.jetty.servlet.AbstractSessionManager.newHttpSession(AbstractSessionManager.java:415)
    at org.mortbay.jetty.Request.getSession(Request.java:1115)
    at
org.apache.tapestry5.internal.services.RequestImpl.getSession(RequestImpl.java:99)
    at $Request_11ff20aaf14.getSession($Request_11ff20aaf14.java)
    at $Request_11ff20aaee2.getSession($Request_11ff20aaee2.java)
    at
org.apache.tapestry5.internal.services.AbstractSessionPersistentFieldStrategy.postChange(AbstractSessionPersistentFieldStrategy.java:124)
    at
org.apache.tapestry5.internal.services.PersistentFieldManagerImpl.postChange(PersistentFieldManagerImpl.java:85)
    at
$PersistentFieldManager_11ff20aaf1a.postChange($PersistentFieldManager_11ff20aaf1a.java)
    at
org.apache.tapestry5.internal.structure.PageImpl.persistFieldChange(PageImpl.java:192)
    at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.persistFieldChange(InternalComponentResourcesImpl.java:257)
    at
org.apache.tapestry5.corelib.components.Form._$write_defaultTracker(Form.java)
    at
org.apache.tapestry5.corelib.components.Form.getDefaultTracker(Form.java:222)
    at $PropertyConduit_11ff20aaf42.get($PropertyConduit_11ff20aaf42.java)
    at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:53)
    at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:284)
    at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:315)
    at
org.apache.tapestry5.corelib.components.Form._$read_parameter_tracker(Form.java)
    at
org.apache.tapestry5.corelib.components.Form.beginRender(Form.java:256)
    at org.apache.tapestry5.corelib.components.Form.beginRender(Form.java)
    at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$11$1.run(ComponentPageElementImpl.java:352)
    at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:925)
    at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$200(ComponentPageElementImpl.java:50)
    at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$11.render(ComponentPageElementImpl.java:356)
    at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
    at
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:121)
    at
$PageRenderQueue_11ff20aaf52.render($PageRenderQueue_11ff20aaf52.java)
    at
$PageRenderQueue_11ff20aaf4a.render($PageRenderQueue_11ff20aaf4a.java)
    at
org.apache.tapestry5.services.TapestryModule$19.renderMarkup(TapestryModule.java:1200)
    at
org.apache.tapestry5.services.TapestryModule$29.renderMarkup(TapestryModule.java:1580)
    at
$MarkupRenderer_11ff20aaf56.renderMarkup($MarkupRenderer_11ff20aaf56.java)
    at
org.apache.tapestry5.services.TapestryModule$28.renderMarkup(TapestryModule.java:1561)
    at
$MarkupRenderer_11ff20aaf56.renderMarkup($MarkupRenderer_11ff20aaf56.java)
    at
org.apache.tapestry5.services.TapestryModule$27.renderMarkup(TapestryModule.java:1543)
    at
$MarkupRenderer_11ff20aaf56.renderMarkup($MarkupRenderer_11ff20aaf56.java)
    at
org.apache.tapestry5.services.TapestryModule$26.renderMarkup(TapestryModule.java:1525)
    at
$MarkupRenderer_11ff20aaf56.renderMarkup($MarkupRenderer_11ff20aaf56.java)
    at
org.apache.tapestry5.services.TapestryModule$25.renderMarkup(TapestryModule.java:1495)
    at
$MarkupRenderer_11ff20aaf56.renderMarkup($MarkupRenderer_11ff20aaf56.java)
    at
$MarkupRenderer_11ff20aaf50.renderMarkup($MarkupRenderer_11ff20aaf50.java)
    at
org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:64)
    at
$PageMarkupRenderer_11ff20aaf4e.renderPageMarkup($PageMarkupRenderer_11ff20aaf4e.java)
    at
org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:57)
    at
$PageResponseRenderer_11ff20aaf0f.renderPageResponse($PageResponseRenderer_11ff20aaf0f.java)
    at
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:59)
    at
org.apache.tapestry5.services.TapestryModule$35.handle(TapestryModule.java:1779)
    at
$PageRenderRequestHandler_11ff20aaf10.handle($PageRenderRequestHandler_11ff20aaf10.java)
    at
$PageRenderRequestHandler_11ff20aaf03.handle($PageRenderRequestHandler_11ff20aaf03.java)
    at
org.apache.tapestry5.internal.services.PageRenderDispatcher.process(PageRenderDispatcher.java:92)
    at
org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:81)
    at $Dispatcher_11ff20aaf09.dispatch($Dispatcher_11ff20aaf09.java)
    at $Dispatcher_11ff20aaefc.dispatch($Dispatcher_11ff20aaefc.java)
    at
org.apache.tapestry5.services.TapestryModule$17.service(TapestryModule.java:1029)
    at bb.test.components.services.AppModule$1.service(AppModule.java:84)
    at $RequestFilter_11ff20aaefb.service($RequestFilter_11ff20aaefb.java)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at
org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at
org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at
org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:621)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:611)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
    at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:83)
    at
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
    at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
    at $RequestHandler_11ff20aaefd.service($RequestHandler_11ff20aaefd.java)
    at $RequestHandler_11ff20aaef3.service($RequestHandler_11ff20aaef3.java)
    at
org.apache.tapestry5.services.TapestryModule$16.service(TapestryModule.java:1007)
    at
org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
    at
$HttpServletRequestFilter_11ff20aaef2.service($HttpServletRequestFilter_11ff20aaef2.java)
    at
$HttpServletRequestHandler_11ff20aaef4.service($HttpServletRequestHandler_11ff20aaef4.java)
    at
$HttpServletRequestHandler_11ff20aaef1.service($HttpServletRequestHandler_11ff20aaef1.java)
    at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:179)
    at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
    at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)


So, the Form clearly is not inheriting the persistence strategy given by
@Meta annotation on a page class. At
http://tapestry.apache.org/tapestry5/guide/persist.html there is a paragraph

Persistence Search

By default the value for the Persist annotation is the empty string. When
this is true, then the actual strategy to be used is determined by a search
up the component hiearchy.

For each component, the meta-data property tapestry.persistence-strategy is
checked. This can be specified using the
Meta<http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/Meta.html>annotation.

If the value is non-blank, then that strategy is used. This allows a
component to control the persistence strategy used inside any sub-components
(that don't explicitly use a different strategy).

In any case, if no component provides the meta data, then the ultimate
default, "session", is used.

I guess Form is not affected by this.

Regards,
Borut




2009/3/10 Andreas Andreou <an...@di.uoa.gr>

> in sessionCreated create and dump an exception and check the stacktrace
> to find who's responsible
>
> On Tue, Mar 10, 2009 at 2:07 AM, Borut Bolčina <bo...@gmail.com>
> wrote:
> > Hi,
> >
> > I am trying to prevent session creation when using forms and in general.
> I
> > searched the mailing list but can not explain why the session is still
> being
> > created. I use 5.0.18.
> >
> > Index.tml
> >
> > <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> >    <body>
> >        <t:form t:id="myform">
> >            <t:label for="cardNumber"/>:
> >            <t:textfield t:id="cardNumber" value="cardNumber" size="20"/>
> >            <input type="submit" value="Submit"/>
> >        </t:form>
> >        <div>${cardNumber}</div>
> >    </body>
> > </html>
> >
> > Index.java
> >
> > @Meta("tapestry.persistence-strategy=client")
> > public class Index {
> >
> >    @Property
> >    @Persist
> >    private String cardNumber;
> >
> > }
> >
> > Even when I remove the @Persist annotation from the cardNumber property,
> the
> > session is still being created. Until I remove the Form from the
> template.
> >
> > I am monitoring session creation with a class in my same test project:
> >
> > package bb.test.session;
> > import java.util.Date;
> >
> > import javax.servlet.http.HttpSession;
> > import javax.servlet.http.HttpSessionEvent;
> > import javax.servlet.http.HttpSessionListener;
> >
> > public class MyHttpSessionListener implements HttpSessionListener {
> >    public void sessionCreated(HttpSessionEvent se)
> >    {
> >        HttpSession session = se.getSession();
> >        System.out.print(getTime() + " (session) Created:");
> >        System.out.println("ID=" + session.getId() + "
> MaxInactiveInterval="
> > + session.getMaxInactiveInterval());
> >    }
> >    public void sessionDestroyed(HttpSessionEvent se)
> >    {
> >        HttpSession session = se.getSession();
> >        // session has been invalidated and all session data (except Id)is
> > no longer available
> >        System.out.println(getTime() + " (session) Destroyed:ID=" +
> > session.getId());
> >    }
> >    private String getTime()
> >    {
> >        return new Date(System.currentTimeMillis()).toString();
> >    }
> >
> > }
> >
> > and with
> >
> >    <listener>
> >
> > <listener-class>bb.test.session.MyHttpSessionListener</listener-class>
> >    </listener>
> >
> > in my web.xml.
> >
> > Of course Firefox extension FireCookie is of help.
> >
> > So, is this a bug?
> >
> > Regards,
> > Borut
> >
>
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @Meta("tapestry.persistence-strategy=client")

Posted by Andreas Andreou <an...@di.uoa.gr>.
in sessionCreated create and dump an exception and check the stacktrace
to find who's responsible

On Tue, Mar 10, 2009 at 2:07 AM, Borut Bolčina <bo...@gmail.com> wrote:
> Hi,
>
> I am trying to prevent session creation when using forms and in general. I
> searched the mailing list but can not explain why the session is still being
> created. I use 5.0.18.
>
> Index.tml
>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>    <body>
>        <t:form t:id="myform">
>            <t:label for="cardNumber"/>:
>            <t:textfield t:id="cardNumber" value="cardNumber" size="20"/>
>            <input type="submit" value="Submit"/>
>        </t:form>
>        <div>${cardNumber}</div>
>    </body>
> </html>
>
> Index.java
>
> @Meta("tapestry.persistence-strategy=client")
> public class Index {
>
>    @Property
>    @Persist
>    private String cardNumber;
>
> }
>
> Even when I remove the @Persist annotation from the cardNumber property, the
> session is still being created. Until I remove the Form from the template.
>
> I am monitoring session creation with a class in my same test project:
>
> package bb.test.session;
> import java.util.Date;
>
> import javax.servlet.http.HttpSession;
> import javax.servlet.http.HttpSessionEvent;
> import javax.servlet.http.HttpSessionListener;
>
> public class MyHttpSessionListener implements HttpSessionListener {
>    public void sessionCreated(HttpSessionEvent se)
>    {
>        HttpSession session = se.getSession();
>        System.out.print(getTime() + " (session) Created:");
>        System.out.println("ID=" + session.getId() + " MaxInactiveInterval="
> + session.getMaxInactiveInterval());
>    }
>    public void sessionDestroyed(HttpSessionEvent se)
>    {
>        HttpSession session = se.getSession();
>        // session has been invalidated and all session data (except Id)is
> no longer available
>        System.out.println(getTime() + " (session) Destroyed:ID=" +
> session.getId());
>    }
>    private String getTime()
>    {
>        return new Date(System.currentTimeMillis()).toString();
>    }
>
> }
>
> and with
>
>    <listener>
>
> <listener-class>bb.test.session.MyHttpSessionListener</listener-class>
>    </listener>
>
> in my web.xml.
>
> Of course Firefox extension FireCookie is of help.
>
> So, is this a bug?
>
> Regards,
> Borut
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: @Meta("tapestry.persistence-strategy=client")

Posted by Robert Zeigler <ro...@scazdl.org>.
Try providing a custom validation tracker to form.
Form creates one that is stored in the session by default.
I suspect this is where your session creation is coming from.

Note that for validation to work properly, you'll have to persist the  
tracker in some form.

Robert

On Mar 9, 2009, at 3/97:07 PM , Borut Bolčina wrote:

> Hi,
>
> I am trying to prevent session creation when using forms and in  
> general. I
> searched the mailing list but can not explain why the session is  
> still being
> created. I use 5.0.18.
>
> Index.tml
>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>    <body>
>        <t:form t:id="myform">
>            <t:label for="cardNumber"/>:
>            <t:textfield t:id="cardNumber" value="cardNumber"  
> size="20"/>
>            <input type="submit" value="Submit"/>
>        </t:form>
>        <div>${cardNumber}</div>
>    </body>
> </html>
>
> Index.java
>
> @Meta("tapestry.persistence-strategy=client")
> public class Index {
>
>    @Property
>    @Persist
>    private String cardNumber;
>
> }
>
> Even when I remove the @Persist annotation from the cardNumber  
> property, the
> session is still being created. Until I remove the Form from the  
> template.
>
> I am monitoring session creation with a class in my same test project:
>
> package bb.test.session;
> import java.util.Date;
>
> import javax.servlet.http.HttpSession;
> import javax.servlet.http.HttpSessionEvent;
> import javax.servlet.http.HttpSessionListener;
>
> public class MyHttpSessionListener implements HttpSessionListener {
>    public void sessionCreated(HttpSessionEvent se)
>    {
>        HttpSession session = se.getSession();
>        System.out.print(getTime() + " (session) Created:");
>        System.out.println("ID=" + session.getId() + "  
> MaxInactiveInterval="
> + session.getMaxInactiveInterval());
>    }
>    public void sessionDestroyed(HttpSessionEvent se)
>    {
>        HttpSession session = se.getSession();
>        // session has been invalidated and all session data (except  
> Id)is
> no longer available
>        System.out.println(getTime() + " (session) Destroyed:ID=" +
> session.getId());
>    }
>    private String getTime()
>    {
>        return new Date(System.currentTimeMillis()).toString();
>    }
>
> }
>
> and with
>
>    <listener>
>
> <listener-class>bb.test.session.MyHttpSessionListener</listener-class>
>    </listener>
>
> in my web.xml.
>
> Of course Firefox extension FireCookie is of help.
>
> So, is this a bug?
>
> Regards,
> Borut


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