4 Replies Latest reply on Jan 27, 2011 3:20 AM by lvdberg

    Session randomly loses user

    alain94040

      I'm facing an amazingly frustrating issue: my session will randomly lose the user, which then crashes everything with an error such as:



      Caused by: org.jboss.seam.RequiredException: @In attribute requires non-null value: currentProject.user



      That button will start a nested conversation, take me to another page, then I close the conversation by clicking on a button on that page. Then I'm back on the first page and start a cycle again.


      The problem does not seem related to any timeout. Sometimes it happens after I click once on a button, sometimes I can click on that button 10 times in a row and everything works fine.


      The action code that is triggered by that button has nothing special on it. Plus, it works 90% of the time. And the problem is not linked to that particular button, the same problem (of eventually losing the session user) happens when I use other actions as well.


      It's quite amazing really! I updated to the latest and greatest 2.2.1CR2, the problem is still there. I found a thread on that site where someone else had the same issue. Upgrading made the problem go away for them, but not for us.


      How do you track who is killing my user object from the session? The debug page clearly shows that the object is gone.


      Any help would be greatly appreciated.

        • 1. Re: Session randomly loses user
          kragoth

          Can we at least get the relevant code sections including what scope you have on your beans etc. When/where is user created. Are new values for user created/set during your nested conversations?


          Nested conversations are a funny beast and last time I checked the doco stilled said that they were not a production ready feature. So it could be something funny going on during the context switching and just lucky/unlucky timings are causing a null value to be picked up during the bijection process.


          But, a little more info would be helpful.

          • 2. Re: Session randomly loses user
            lvdberg

            Hi,


            Code will be very helpful, but as a first guess: do you by any chance outject the user var more than once in you application or have you manually set timeouts for your pages?


            I ONLY outject the currentUser directly after authenticating him/her and only loose the user (context-var) after an automatic session closure. Under normal conditions the user (and its related organisation) stays available without a problem.


            Leo

            • 3. Re: Session randomly loses user
              lceni

              I have the same problem, I'm going crazy!
              Seems to be magic. As you told, 90% of time works perfectly but then I click in some link or button, the application executes an action and redirect the user to the login page informing that the user isn't logged in.


              I was suspecting to be something about the Transaction manager then I've used the same configuration found at jpa example project but didn't fix.


              The problem is that Seam doesn't inform what happened, even in debug mode. We need to spend a lot of time debugging the framework's classes to try to discover something.


              Other day I changed my persistence-context name from entityManager to em and then the application started to throw a misteriously NPE. Trying to figure out what happened, I found here on forum some users w/ the same problem when using a s:convertEntity that internally uses the entityManager reference to get from cache or DB the correct entity being converted.


              So, my complain is about the seam error messages that makes the framework to be NOT self-explained, different of others that when you get an exception you know exactly where is the error only reading its message.


              Lucas

              • 4. Re: Session randomly loses user
                lvdberg

                Hi,


                repeating the remark in my previous email. Please send in your code and do some additional debugging.
                If you create a session scoped bean, call from the Authentication code (or whatever other bean in your session) you user data, when the session times out the destroy method will be called and the name of the user will be printed. Put some Date-stuff in it and you can see exactly when it happens.


                so:


                So something like:





                @Scope(SESSION)
                public class CheckIt implements Ser...{
                
                @Logger Log log;
                
                private User you;
                
                public putUserData(User user){
                 you = user;
                }
                
                @Destroy
                public whoWsDisConnected(){
                 log.info("The disconnected user is....." + you.getFullName());
                }
                }






                Leo