Re: SessionState problems with a String type
I'm replying to this somewhat old thread just to say that I have found the problem. The problem was that I had stored something as a SessionState Object (SSO), then I forwarded the user to another website to do some authentication which forwarded the user back to my site. But when the user came back to me site, the SSO was null. Correction: it was /sometimes/ null. Sometimes it worked fine. Why was that? After much scratching of my head I found the answer, and it was a very simple answer. The URL of the site I was originally on didn't have the www. in front of it. But when the authenticating site forwarded the user back to my site, it used the URL with www. in front, thus causing it to be a different site with different cookies, thus a different session id, and thus different SSOs. Thank you to this great community for good suggestions. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 2:17 PM, Tim Koop wrote: Well, I just tried checking the session id like this, and it is in fact the same after coming back. And the SessionState objects started working too! So then I took out this session id code, and the SessionState objects are still working. So now it's all working fine, and I am left scratching my head wondering why. Thank you both for your ideas. Maybe something fixed it, but I don't know what. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 1:33 PM, Josh Canfield wrote: Are you sure you're getting the same session when you come back to the page? try dumping the session id. @Inject private HttpServletRequest request; void onActivate() { final HttpSession session = request.getSession(false); log.debug(session == null ? Null session : (Session Id: + session.getId())); } Josh On Wed, May 11, 2011 at 11:17 AM, Tim Koopt...@timkoop.com wrote: Thanks Josh (and Thiago). I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? And no, I don't plan to actually use a String as a SessionState Object. I'm just testing with it. Thanks. Tim Koop t...@timkoop.commailto:t...@timkoop.com www.timkoop.comhttp://www.timkoop.com On 11/05/2011 12:39 PM, Josh Canfield wrote: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionState.html Specifically: public abstract boolean create If true (the default), then referencing an field marked with the annotation will create the SSO. If false, then accessing the field will not create the SSO, it will only allow access to it if it already exists. Default: true This thread might be helpful. http://tapestry.1045711.n5.nabble.com/SessionState-for-simple-types-td2839381.html or this one http://tapestry.1045711.n5.nabble.com/SessionState-error-td2432233.html Josh On Wed, May 11, 2011 at 10:01 AM, Tim Koopt...@timkoop.comwrote: I'm having a little problem with even a simple SessionState String object. On one page I have this: @SessionState private String userColour; ... userColour = red; Then on a subsequent page I have this: @SessionState private String userColour; ... System.out.println(colour is + userColour); But instead of printing red, the page throws the following error. It looks to me like it is trying to recreate the String object from a fancy constructor. But it isn't supposed to recreate the object, is it? Isn't is supposed to store the object in memory just the way it is without recreating it with a constructor? An unexpected application exception has occurred. * org.apache.tapestry5.runtime.ComponentEventException Error invoking constructor java.lang.String(byte[], int, int, int) (at String.java:337) (for service 'ApplicationStateManager'): No service implements the interface [B. context eventType activate * org.apache.tapestry5.ioc.internal.OperationException No service implements the interface [B. trace o Triggering event 'activate' on login/OpenId o Instantiating instance of SSO class java.lang.String o Determining injection value for parameter #1 (byte[]) o Resolving object of type byte[] using MasterObjectProvider * java.lang.RuntimeException No service implements the interface [B. Hide uninteresting stack frames Stack
Re: SessionState problems with a String type
Ha! Good catch, and annoying. For anyone who hasn't addressed this, when I'm in apache fronted tomcat I use a rewrite rule in apache to make sure everything goes to the www. url... I suppose you could also do the same thing in a Tapestry request filter. Josh On Wed, Jun 29, 2011 at 9:35 AM, Tim Koop t...@timkoop.com wrote: I'm replying to this somewhat old thread just to say that I have found the problem. The problem was that I had stored something as a SessionState Object (SSO), then I forwarded the user to another website to do some authentication which forwarded the user back to my site. But when the user came back to me site, the SSO was null. Correction: it was /sometimes/ null. Sometimes it worked fine. Why was that? After much scratching of my head I found the answer, and it was a very simple answer. The URL of the site I was originally on didn't have the www. in front of it. But when the authenticating site forwarded the user back to my site, it used the URL with www. in front, thus causing it to be a different site with different cookies, thus a different session id, and thus different SSOs. Thank you to this great community for good suggestions. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 2:17 PM, Tim Koop wrote: Well, I just tried checking the session id like this, and it is in fact the same after coming back. And the SessionState objects started working too! So then I took out this session id code, and the SessionState objects are still working. So now it's all working fine, and I am left scratching my head wondering why. Thank you both for your ideas. Maybe something fixed it, but I don't know what. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 1:33 PM, Josh Canfield wrote: Are you sure you're getting the same session when you come back to the page? try dumping the session id. @Inject private HttpServletRequest request; void onActivate() { final HttpSession session = request.getSession(false); log.debug(session == null ? Null session : (Session Id: + session.getId())); } Josh On Wed, May 11, 2011 at 11:17 AM, Tim Koopt...@timkoop.com wrote: Thanks Josh (and Thiago). I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? And no, I don't plan to actually use a String as a SessionState Object. I'm just testing with it. Thanks. Tim Koop t...@timkoop.commailto:t...@timkoop.com www.timkoop.comhttp://www.timkoop.com On 11/05/2011 12:39 PM, Josh Canfield wrote: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionState.html Specifically: public abstract boolean create If true (the default), then referencing an field marked with the annotation will create the SSO. If false, then accessing the field will not create the SSO, it will only allow access to it if it already exists. Default: true This thread might be helpful. http://tapestry.1045711.n5.nabble.com/SessionState-for-simple-types-td2839381.html or this one http://tapestry.1045711.n5.nabble.com/SessionState-error-td2432233.html Josh On Wed, May 11, 2011 at 10:01 AM, Tim Koopt...@timkoop.com wrote: I'm having a little problem with even a simple SessionState String object. On one page I have this: @SessionState private String userColour; ... userColour = red; Then on a subsequent page I have this: @SessionState private String userColour; ... System.out.println(colour is + userColour); But instead of printing red, the page throws the following error. It looks to me like it is trying to recreate the String object from a fancy constructor. But it isn't supposed to recreate the object, is it? Isn't is supposed to store the object in memory just the way it is without recreating it with a constructor? An unexpected application exception has occurred. * org.apache.tapestry5.runtime.ComponentEventException Error invoking constructor java.lang.String(byte[], int, int, int) (at String.java:337) (for service 'ApplicationStateManager'): No service implements the interface [B. context eventType activate * org.apache.tapestry5.ioc.internal.OperationException No service implements the interface [B. trace o Triggering
Re: SessionState problems with a String type
On Wed, 29 Jun 2011 15:20:48 -0300, Josh Canfield joshcanfi...@gmail.com wrote: Ha! Good catch, and annoying. For anyone who hasn't addressed this, when I'm in apache fronted tomcat I use a rewrite rule in apache to make sure everything goes to the www. url... I suppose you could also do the same thing in a Tapestry request filter. That's exactly how the old Tapestry URL rewriter API was implemented. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: SessionState problems with a String type
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionState.html Specifically: public abstract boolean create If true (the default), then referencing an field marked with the annotation will create the SSO. If false, then accessing the field will not create the SSO, it will only allow access to it if it already exists. Default: true This thread might be helpful. http://tapestry.1045711.n5.nabble.com/SessionState-for-simple-types-td2839381.html or this one http://tapestry.1045711.n5.nabble.com/SessionState-error-td2432233.html Josh On Wed, May 11, 2011 at 10:01 AM, Tim Koop t...@timkoop.com wrote: I'm having a little problem with even a simple SessionState String object. On one page I have this: @SessionState private String userColour; ... userColour = red; Then on a subsequent page I have this: @SessionState private String userColour; ... System.out.println(colour is + userColour); But instead of printing red, the page throws the following error. It looks to me like it is trying to recreate the String object from a fancy constructor. But it isn't supposed to recreate the object, is it? Isn't is supposed to store the object in memory just the way it is without recreating it with a constructor? An unexpected application exception has occurred. * org.apache.tapestry5.runtime.ComponentEventException Error invoking constructor java.lang.String(byte[], int, int, int) (at String.java:337) (for service 'ApplicationStateManager'): No service implements the interface [B. context eventType activate * org.apache.tapestry5.ioc.internal.OperationException No service implements the interface [B. trace o Triggering event 'activate' on login/OpenId o Instantiating instance of SSO class java.lang.String o Determining injection value for parameter #1 (byte[]) o Resolving object of type byte[] using MasterObjectProvider * java.lang.RuntimeException No service implements the interface [B. Hide uninteresting stack frames Stack trace o org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:665) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl$1.invoke(MasterObjectProviderImpl.java:56) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:41) o org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:806) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:50) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:233) o org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:60) o org.apache.tapestry5.ioc.internal.util.InternalUtils$2.invoke(InternalUtils.java:273) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:277) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForConstructor(InternalUtils.java:248) o org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:56) o org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$4.invoke(ServiceResourcesImpl.java:160) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:146) o org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$1.create(ApplicationStateManagerImpl.java:104) o org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getOrCreate(SessionApplicationStatePersistenceStrategy.java:57)
Re: SessionState problems with a String type
Thanks Josh (and Thiago). I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? And no, I don't plan to actually use a String as a SessionState Object. I'm just testing with it. Thanks. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 12:39 PM, Josh Canfield wrote: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionState.html Specifically: public abstract boolean create If true (the default), then referencing an field marked with the annotation will create the SSO. If false, then accessing the field will not create the SSO, it will only allow access to it if it already exists. Default: true This thread might be helpful. http://tapestry.1045711.n5.nabble.com/SessionState-for-simple-types-td2839381.html or this one http://tapestry.1045711.n5.nabble.com/SessionState-error-td2432233.html Josh On Wed, May 11, 2011 at 10:01 AM, Tim Koopt...@timkoop.com wrote: I'm having a little problem with even a simple SessionState String object. On one page I have this: @SessionState private String userColour; ... userColour = red; Then on a subsequent page I have this: @SessionState private String userColour; ... System.out.println(colour is + userColour); But instead of printing red, the page throws the following error. It looks to me like it is trying to recreate the String object from a fancy constructor. But it isn't supposed to recreate the object, is it? Isn't is supposed to store the object in memory just the way it is without recreating it with a constructor? An unexpected application exception has occurred. * org.apache.tapestry5.runtime.ComponentEventException Error invoking constructor java.lang.String(byte[], int, int, int) (at String.java:337) (for service 'ApplicationStateManager'): No service implements the interface [B. context eventType activate * org.apache.tapestry5.ioc.internal.OperationException No service implements the interface [B. trace o Triggering event 'activate' on login/OpenId o Instantiating instance of SSO class java.lang.String o Determining injection value for parameter #1 (byte[]) o Resolving object of type byte[] using MasterObjectProvider * java.lang.RuntimeException No service implements the interface [B. Hide uninteresting stack frames Stack trace o org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:665) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl$1.invoke(MasterObjectProviderImpl.java:56) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:41) o org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:806) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:50) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:233) o org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:60) o org.apache.tapestry5.ioc.internal.util.InternalUtils$2.invoke(InternalUtils.java:273) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:277) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForConstructor(InternalUtils.java:248) o org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:56)
Re: SessionState problems with a String type
On Wed, 11 May 2011 15:17:42 -0300, Tim Koop t...@timkoop.com wrote: Thanks Josh (and Thiago). You're welcome! I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. That's strange. I've never seen this kind of bug. Are you sure you haven't any other @SessionState field with type String? If yes and it's set to null somewhere, the bug is in your code. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? I don't think so. Why are you returning an URL object to redirect to a page in your application? Return the page Class instance or one instance of the page obtained through a field with @InjectPage. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: SessionState problems with a String type
Are you sure you're getting the same session when you come back to the page? try dumping the session id. @Inject private HttpServletRequest request; void onActivate() { final HttpSession session = request.getSession(false); log.debug(session == null ? Null session : (Session Id: + session.getId())); } Josh On Wed, May 11, 2011 at 11:17 AM, Tim Koop t...@timkoop.com wrote: Thanks Josh (and Thiago). I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? And no, I don't plan to actually use a String as a SessionState Object. I'm just testing with it. Thanks. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 12:39 PM, Josh Canfield wrote: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionState.html Specifically: public abstract boolean create If true (the default), then referencing an field marked with the annotation will create the SSO. If false, then accessing the field will not create the SSO, it will only allow access to it if it already exists. Default: true This thread might be helpful. http://tapestry.1045711.n5.nabble.com/SessionState-for-simple-types-td2839381.html or this one http://tapestry.1045711.n5.nabble.com/SessionState-error-td2432233.html Josh On Wed, May 11, 2011 at 10:01 AM, Tim Koopt...@timkoop.com wrote: I'm having a little problem with even a simple SessionState String object. On one page I have this: @SessionState private String userColour; ... userColour = red; Then on a subsequent page I have this: @SessionState private String userColour; ... System.out.println(colour is + userColour); But instead of printing red, the page throws the following error. It looks to me like it is trying to recreate the String object from a fancy constructor. But it isn't supposed to recreate the object, is it? Isn't is supposed to store the object in memory just the way it is without recreating it with a constructor? An unexpected application exception has occurred. * org.apache.tapestry5.runtime.ComponentEventException Error invoking constructor java.lang.String(byte[], int, int, int) (at String.java:337) (for service 'ApplicationStateManager'): No service implements the interface [B. context eventType activate * org.apache.tapestry5.ioc.internal.OperationException No service implements the interface [B. trace o Triggering event 'activate' on login/OpenId o Instantiating instance of SSO class java.lang.String o Determining injection value for parameter #1 (byte[]) o Resolving object of type byte[] using MasterObjectProvider * java.lang.RuntimeException No service implements the interface [B. Hide uninteresting stack frames Stack trace o org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:665) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl$1.invoke(MasterObjectProviderImpl.java:56) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:41) o org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:806) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:50) o org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:233) o org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:60) o org.apache.tapestry5.ioc.internal.util.InternalUtils$2.invoke(InternalUtils.java:273) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o
Re: SessionState problems with a String type
I'm trying to authenticate on my website with OpenID, using Java code from the openid4java library. After the user specifies his OpenID provider, the server (Tapestry) is supposed to forward him to the appropriate web page (like Google) to get authenticated, then it forwards the user back to my website. This works, except I am supposed to keep track of certain Discovery Information (the org.openid4java.discovery.DiscoveryInformation object) in the session. It doesn't stick. And neither does even a simple String object. Maybe when the authenticating site forwards the user back to my site, Tapestry forgets the session... Hang on. I just got Josh's email. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 1:25 PM, Thiago H. de Paula Figueiredo wrote: On Wed, 11 May 2011 15:17:42 -0300, Tim Koop t...@timkoop.com wrote: Thanks Josh (and Thiago). You're welcome! I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. That's strange. I've never seen this kind of bug. Are you sure you haven't any other @SessionState field with type String? If yes and it's set to null somewhere, the bug is in your code. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? I don't think so. Why are you returning an URL object to redirect to a page in your application? Return the page Class instance or one instance of the page obtained through a field with @InjectPage. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: SessionState problems with a String type
On Wed, 11 May 2011 15:35:15 -0300, Tim Koop t...@timkoop.com wrote: I'm trying to authenticate on my website with OpenID, using Java code from the openid4java library. After the user specifies his OpenID provider, the server (Tapestry) is supposed to forward him to the appropriate web page (like Google) to get authenticated, then it forwards the user back to my website. Ah! Now it makes a lot of sense. :) This works, except I am supposed to keep track of certain Discovery Information (the org.openid4java.discovery.DiscoveryInformation object) in the session. It doesn't stick. And neither does even a simple String object. Maybe when the authenticating site forwards the user back to my site, Tapestry forgets the session... Hang on. I just got Josh's email. Josh's probably right. Do you have cookies enabled? -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: SessionState problems with a String type
Well, I just tried checking the session id like this, and it is in fact the same after coming back. And the SessionState objects started working too! So then I took out this session id code, and the SessionState objects are still working. So now it's all working fine, and I am left scratching my head wondering why. Thank you both for your ideas. Maybe something fixed it, but I don't know what. Tim Koop t...@timkoop.com mailto:t...@timkoop.com www.timkoop.com http://www.timkoop.com On 11/05/2011 1:33 PM, Josh Canfield wrote: Are you sure you're getting the same session when you come back to the page? try dumping the session id. @Inject private HttpServletRequest request; void onActivate() { final HttpSession session = request.getSession(false); log.debug(session == null ? Null session : (Session Id: + session.getId())); } Josh On Wed, May 11, 2011 at 11:17 AM, Tim Koopt...@timkoop.com wrote: Thanks Josh (and Thiago). I added (create = false), and this certainly got rid of the error message. However, my session object is still either not getting set correctly (even though I clearly visit the page where it gets set, and I even write a message to the log saying I was there), or it isn't being retrieved correctly, because it is null when I want to read it. My only thought is this: On the page where I set the session object, that page returns a java.net.URL object, redirecting the browser to another page. Perhaps this is preventing the session object from being stored correctly? And no, I don't plan to actually use a String as a SessionState Object. I'm just testing with it. Thanks. Tim Koop t...@timkoop.commailto:t...@timkoop.com www.timkoop.comhttp://www.timkoop.com On 11/05/2011 12:39 PM, Josh Canfield wrote: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionState.html Specifically: public abstract boolean create If true (the default), then referencing an field marked with the annotation will create the SSO. If false, then accessing the field will not create the SSO, it will only allow access to it if it already exists. Default: true This thread might be helpful. http://tapestry.1045711.n5.nabble.com/SessionState-for-simple-types-td2839381.html or this one http://tapestry.1045711.n5.nabble.com/SessionState-error-td2432233.html Josh On Wed, May 11, 2011 at 10:01 AM, Tim Koopt...@timkoop.comwrote: I'm having a little problem with even a simple SessionState String object. On one page I have this: @SessionState private String userColour; ... userColour = red; Then on a subsequent page I have this: @SessionState private String userColour; ... System.out.println(colour is + userColour); But instead of printing red, the page throws the following error. It looks to me like it is trying to recreate the String object from a fancy constructor. But it isn't supposed to recreate the object, is it? Isn't is supposed to store the object in memory just the way it is without recreating it with a constructor? An unexpected application exception has occurred. * org.apache.tapestry5.runtime.ComponentEventException Error invoking constructor java.lang.String(byte[], int, int, int) (at String.java:337) (for service 'ApplicationStateManager'): No service implements the interface [B. context eventType activate * org.apache.tapestry5.ioc.internal.OperationException No service implements the interface [B. trace o Triggering event 'activate' on login/OpenId o Instantiating instance of SSO class java.lang.String o Determining injection value for parameter #1 (byte[]) o Resolving object of type byte[] using MasterObjectProvider * java.lang.RuntimeException No service implements the interface [B. Hide uninteresting stack frames Stack trace o org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:665) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl$1.invoke(MasterObjectProviderImpl.java:56) o org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) o org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) o org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1057) o org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:41) o org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:806) o org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:50) o