• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The glassfish session failed

 
Pawel Skadorwa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,

There is a problem with glassfish session and I don't really know how to resolve it. I developed JSF application based on JSF 2.1 and noticed strange feature. When the app was tested by many users in the same time, they could see their data given in the inputtexts. Another words when one of them retrieved data into a form, the other who open the same form was able to read that data. Can it be a problem with session? I didn't notice a jsessionid in URL. Please give me some tips that will help me to solve that problem. Thank you very much in advance.
 
Brendan Healey
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

By default JSF uses a jsessionid cookie in preference to URL rewriting. It sounds like your users are somehow connecting to the
same session, are you using @SessionScoped backing beans? Are they connecting up from the same browser or using different
computers? Are cookies enabled on the browsers?
 
Pawel Skadorwa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly it seems to be the same session. They use different computers, are connecting from different locations, cookies are enabled but if it comes to the session scope it looks like this:



Everything looks as if it was correct but it doesn't work. I don't have any idea how to repair it. Have you got any idea about the reason of such behaviour.
I want to add that I use xhtml pages and web.xml looks like this:

 
Pawel Skadorwa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It happens when I use static variables. When I want to use only public then data isn't displayed. Any ideas?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Skadorwa wrote:It happens when I use static variables. When I want to use only public then data isn't displayed. Any ideas?


Yes. Do not use static variables. By definition, static variables belong to the class, not to the instance and there's only one set of them no matter how many instances of the class may exist.

That's not even JSF-specific. It's fundamental Java.
 
Pawel Skadorwa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right! The problem has been solved. Static variables caused such a mistake. Thank you very much for your help. I appreciate it.


 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people would argue that static variables should never be used in J2EE apps - that truly shared objects should be placed in Application Scope, instead.

I'm not that hot for mindless ideology myself, but I do prefer not to use them. In any event, shared objects should only be accessed in a thread-safe way, since J2EE is a heavily multi-threaded environment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic