In tomcat-deployment-scenario we have encountered 
similar problems, when the container's JSESSIONID cookie
is not sent by the request. This might happen, 
eg. if a custom http-client is used. 

In tomcat-deployment the wosid and
the Servlet-Container's JSESSIONID are not equal, although
they are mapped 1:1. Requests have to send both.

regards
Frank

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> pple.com]O
> n Behalf Of Lachlan Deck
> Sent: Wednesday, June 20, 2007 8:10 AM
> To: WebObjects Dev Apple
> Subject: direct action restoring sessions from cookies problem (Ajax)
> 
> 
> Hi there,
> 
> I'm seeing a weird thing where DirectAction's getSessionIDForRequest  
> is being called (by the default request-reponse loop stuff) and is  
> returning a valid sesionId but it actually doesn't attach a session  
> to the current context.
> 
> Any ideas why? (This is during an Ajax direct action request if  
> that's of any interest).
> 
> // here's a work-a-round, but I don't understand why the default  
> mechanism wasn't working.
> public DirectAction( WORequest aRequest ) {
>       super( aRequest );
>       NSLog.debug.appendln( "<init hasSession>" + 
> context().hasSession() );
>       String sessionId = this.getSessionIDForRequest( request() );
>       if ( sessionId != null ) {
>               NSLog.debug.appendln( "<init restoreSession>" );
>               Application.application().restoreSessionWithID( 
> sessionId, context 
> () );
>       }
> }
> 
> Thanks.
> 
> ---- Session ----
> public Session() {
>       super();
>       setStoresIDsInURLs( false );
>       setStoresIDsInCookies( true );
> }
> // btw Session extends ERXSession
> 
> ---- DirecAction ----
> public String getSessionIDForRequest(WORequest aRequest) {
>       String result = super.getSessionIDForRequest( aRequest );
>       NSLog.debug.appendln( "getSessionIDForRequest:" + result );
>       NSLog.debug.appendln( new Exception() );
>       return super.getSessionIDForRequest( aRequest );
> }
> public WOActionResults ajaxUpdateAction() {
>       NSLog.debug.appendln( "ajaxUpdateAction hasSession?" + context 
> ().hasSession() );
>       return pageWithName( AjaxShortlist.class.getName() );
> }
> 
> ---- MyComponent ----
> public void appendToResponse( WOResponse aResponse, WOContext  
> aContext ) {
>       super.appendToResponse( aResponse, aContext );  
>       NSLog.debug.appendln( "hasSession? " + this.hasSession() );
>       NSLog.debug.appendln( "Cookies: " + 
> aContext.request().cookieValues 
> () );
> }
> 
> ---- CONSOLE OUTPUT ----
> Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG  
> NSLog  - getSessionIDForRequest:bGCOTztdVZ0ZyNfmIUc4F0
> [2007-06-20 16:00:31 EST] <WorkerThread11> java.lang.Exception
>       at 
> my.app.DirectAction.getSessionIDForRequest(DirectAction.java:47)
>       at  
> com.webobjects.appserver.WOAction.initializeRequestSessionIDInContext 
> (WOAction.java:74)
>       at com.webobjects.appserver.WOAction.<init>(WOAction.java:24)
>       at com.webobjects.appserver.WODirectAction.<init> 
> (WODirectAction.java:78)
>       at my.app.DirectAction.<init>(DirectAction.java:15)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native  
> Method)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance 
> (NativeConstructorAccessorImpl.java:39)
>       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance 
> (DelegatingConstructorAccessorImpl.java:27)
>       at 
> java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>       at com.webobjects.foundation._NSUtilities.instantiateObject 
> (_NSUtilities.java:575)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler.getAc
> tionInstan 
> ce(WOActionRequestHandler.java:179)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler._hand
> leRequest( 
> WOActionRequestHandler.java:229)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler.handl
> eRequest 
> (WOActionRequestHandler.java:142)
>       at er.extensions.ERXDirectActionRequestHandler.handleRequest 
> (ERXDirectActionRequestHandler.java:82)
>       at com.webobjects.appserver.WOApplication.dispatchRequest 
> (WOApplication.java:1306)
>       at 
> er.extensions.ERXApplication.dispatchRequest(ERXApplication.java: 
> 1041)
>       at com.webobjects.appserver._private.WOWorkerThread.runOnce 
> (WOWorkerThread.java:173)
>       at com.webobjects.appserver._private.WOWorkerThread.run 
> (WOWorkerThread.java:254)
>       at java.lang.Thread.run(Thread.java:613)
> 
> === begin work-around ===
> Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG  
> NSLog  - <init hasSession>false
> Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG  
> NSLog  - getSessionIDForRequest:bGCOTztdVZ0ZyNfmIUc4F0
> [2007-06-20 16:00:31 EST] <WorkerThread11> java.lang.Exception
>       at 
> my.app.DirectAction.getSessionIDForRequest(DirectAction.java:47)
>       at my.app.DirectAction.<init>(DirectAction.java:17)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native  
> Method)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance 
> (NativeConstructorAccessorImpl.java:39)
>       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance 
> (DelegatingConstructorAccessorImpl.java:27)
>       at 
> java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>       at com.webobjects.foundation._NSUtilities.instantiateObject 
> (_NSUtilities.java:575)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler.getAc
> tionInstan 
> ce(WOActionRequestHandler.java:179)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler._hand
> leRequest( 
> WOActionRequestHandler.java:229)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler.handl
> eRequest 
> (WOActionRequestHandler.java:142)
>       at er.extensions.ERXDirectActionRequestHandler.handleRequest 
> (ERXDirectActionRequestHandler.java:82)
>       at com.webobjects.appserver.WOApplication.dispatchRequest 
> (WOApplication.java:1306)
>       at 
> er.extensions.ERXApplication.dispatchRequest(ERXApplication.java: 
> 1041)
>       at com.webobjects.appserver._private.WOWorkerThread.runOnce 
> (WOWorkerThread.java:173)
>       at com.webobjects.appserver._private.WOWorkerThread.run 
> (WOWorkerThread.java:254)
>       at java.lang.Thread.run(Thread.java:613)
> 
> Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG  
> NSLog  - <init restoreSession>
> Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:38) INFO   
> NSLog  - restoreSession trace:
> [2007-06-20 16:00:31 EST] <WorkerThread11> java.lang.Exception
>       at my.app.Application.restoreSessionWithID(Application.java:38)
>       at my.app.DirectAction.<init>(DirectAction.java:20)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native  
> Method)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance 
> (NativeConstructorAccessorImpl.java:39)
>       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance 
> (DelegatingConstructorAccessorImpl.java:27)
>       at 
> java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>       at com.webobjects.foundation._NSUtilities.instantiateObject 
> (_NSUtilities.java:575)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler.getAc
> tionInstan 
> ce(WOActionRequestHandler.java:179)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler._hand
> leRequest( 
> WOActionRequestHandler.java:229)
>       at  
> com.webobjects.appserver._private.WOActionRequestHandler.handl
> eRequest 
> (WOActionRequestHandler.java:142)
>       at er.extensions.ERXDirectActionRequestHandler.handleRequest 
> (ERXDirectActionRequestHandler.java:82)
>       at com.webobjects.appserver.WOApplication.dispatchRequest 
> (WOApplication.java:1306)
>       at 
> er.extensions.ERXApplication.dispatchRequest(ERXApplication.java: 
> 1041)
>       at com.webobjects.appserver._private.WOWorkerThread.runOnce 
> (WOWorkerThread.java:173)
>       at com.webobjects.appserver._private.WOWorkerThread.run 
> (WOWorkerThread.java:254)
>       at java.lang.Thread.run(Thread.java:613)
> === end work-around ===
> Jun 20 16:00:31 MyApp[55397] (ERXNSLogLog4jBridge.java:44) DEBUG  
> NSLog  - ajaxUpdateAction hasSession? false
> Jun 20 16:00:31 MyApp[55397] (AjaxShortlist.java:30) DEBUG  
> my.app.MyComponent  - hasSession? false
> Jun 20 16:00:31 MyApp[55397] (AjaxShortlist.java:31) DEBUG  
> my.app.MyComponent  - Cookies: {wosid = ("bGCOTztdVZ0ZyNfmIUc4F0");  
> woinst = ("-1"); }
> 
> These last couple of lines show true with the work-around in place...
> 
> with regards,
> --
> 
> Lachlan Deck
> 
> 
> 
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/webobjec
ts%40symposion.de

This email sent to [EMAIL PROTECTED]
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to