-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Strange "session" Problem
PostPosted: Mon Nov 10, 2008 6:28 pm 
Newbie

Joined: Mon Nov 10, 2008 6:13 pm
Posts: 4
Hi everyone,

I have a strange problem and I'm quite sure that it's easy to solve. I'm using spring + hibernate framework in our application and i think something is missing in the picture.

Here's an example.

When I log in to our application from my desk top (PC1) as myself and log in to another PC (PC2) with another log in name and play around in both PC's I can suddenly see the data which should be seen only in my login in the PC 1 and vice versa.

Man.... this drives me crazy. I know that I'm missing something or some configuration is not done properly.

Please if you have any idea what is a miss, let me know.

Thanks a ton!

MH


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 10:21 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Well, I guess the obvious question now is:
By what mechanism(s) were you trying to cause that only certain users saw data corresponding to them?

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 12, 2008 10:50 am 
Newbie

Joined: Mon Nov 10, 2008 6:13 pm
Posts: 4
Gonzalo,

Thank you for your response. I don't exactly understand what is your question.

The mechanisms I'm using is Spring Framework and Hibernate. The problem seems to be that somehow the alive session (which is started first) is visible to all users who log in the application instead that the user who log in would ONLY see it. Or USER1 logs in first and when USER2 logs in (after USER1) USER2 is some cases can see the data that only USER1 should see.

Me think that I have made a mistake in Spring Framework session listeners configurations.

If you or anyone has an idea what I'm missing I really appreciate help.

MH


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 12, 2008 11:12 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
How do you obtain the sessions, exactly?
Do you have OSIV configured, and get the current session from SessionFactory?

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 12, 2008 11:22 am 
Newbie

Joined: Mon Nov 10, 2008 6:13 pm
Posts: 4
Gonzales,

I obtain the session in login as request.getSession(true) and request.getSession(false) until logout.

I think that this is the main problem. Do I need to use session from SessionFactory instead of request.getSession()?

Hmmm... that would make more sense alright.

MH


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 12, 2008 2:52 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
(My first name is Gonzalo, last name Díaz).

Yes!
The "session" you can get from the request is an http Session (javax.servlet.http.HTTPSession), nothing to do with a Hibernate session (org.hibernate.Session).

And you cannot reuse the same Hibernate session all across your application. On the contrary, you should obtain the current Hibernate Session via SessionFactory.getCurrentSession(false) in your Java UI code.

The creation/reuse of these Hibernate sessions that you obtain with this method, is something Hibernate itself doesn't manage, so that is why you need a "managed environment" (such as Spring) in order to "pool" those sessions adequately.

In an article of mine here:

http://hibernar.org/articulos_en/spring ... xample.php

I explain in detail a minimal Spring+Hibernate setup, that you can use as a guideline.

_________________
Gonzalo Díaz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.