aspose file tools*
The moose likes JForum and the fly likes Error while executing SSO actions: java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Error while executing SSO actions: java.lang.NullPointerException" Watch "Error while executing SSO actions: java.lang.NullPointerException" New topic
Author

Error while executing SSO actions: java.lang.NullPointerException

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Ok thanks for your help and suggestions Sid, you have certainly cleared up a few things for me. I will try playing with the cookie and see what happens.. I will let you know when I get it working and how.

Thanks again


[originally posted on jforum.net by snowman999]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hurray! i got it to work thanks to your suggestion Sid.

The key thing was setting the "domain" attribute of the cookie when I created it.

So a cookie created by www.mysite.com would have a domain value of ".mysite.com" and then this could be read by forum.mysite.com.

I am doing this now -> :lol:

Thanks!
[originally posted on jforum.net by snowman999]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi guys

My application sets a session cookie called "username" when a user logs in. I am setting it via JavaScript. I can see it is being set by using the "View Cookie Information" tool in the Firefox developer toolbar.

I have set up JForum to use SSO and I have written a class which implements SSO and updated SystemGlobals.properties accordingly, as described in the docs.

I login to my site and then click on "Forum" which opens JForum in a new window. My SSO class is being called fine (as I can see from the server logs), but I am getting the error :

I can see it is falling over on the line that retrieves the cookie :

My question is, would anyone know why getCookie(...) is unable to find the session cookie, even though it is there? And how am I able to fix it (more importantly!)

Thanks in advance



[originally posted on jforum.net by snowman999]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Check for the path that the cookie is valid for

First thing is: both applications have to be hosted on the very same server (same domain!)

Next thing is: cookies have a "path" attribute. If you specify the context name for the path, only those apps that have the very same path are allowed to query that cookie.

So you have to make sure that both - the writing and the reading app - have an empty path so that you read the root directory of the domain ...

Also note that when setting a cookie via javascript the notation of name/value may be weird. Ensure that the name is really the name and not maybe the value ;)

Debug the jforum app and see what cookies you can read from the request. MAybe it's there, but with a different name than expected.
[originally posted on jforum.net by Sid]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi Sid

Thanks for the quick reply. Here is the data in my cookie :

Name username
Value snowman999
Host mysitedev.snowman999.com
Path /
Secure No
Expires At End Of Session

The applications are hosted on the same server, under the same instance of Tomcat, but at different domains. Would this be an issue do you think?

Thanks!

[originally posted on jforum.net by snowman999]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Yes, that's the reason. It has to be same domain as mentioned. Otherwise any website on the net could access any of your local cookies ;)

Cookies can only be read from the same domain that they have been written from.
[originally posted on jforum.net by Sid]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thanks again for the quick reply!

Ok this makes sense to me now I should have spotted this.

I debugged JForum, as you suggested, and the cookie I am looking for is not in the request, for the reason you have described.

So I guess this would work ? :

Site hosted at http://www.some-url.com/

Forum hosted at http://forum.some-url.com/

This way I can still keep both apps seperate (from a server point of view), but they are hosted under the same domain..

Thanks again!
[originally posted on jforum.net by snowman999]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
You're welcome.

The last suggestion of yours should work. But you best give it a try and see yourself ;) I'm not totally sure which part of the domain will be saved as domain attribute within the cookie.

Ah - when I remember right, there was some implementations of cookie that allow setting the domain name too. Maybe you could use the old network structure and just set the cookie not for the current domain but for the different domain. Not sure if that also may work ... just a shot in the dark
[originally posted on jforum.net by Sid]
 
Consider Paul's rocket mass heater.
 
subject: Error while executing SSO actions: java.lang.NullPointerException