10 Replies Latest reply on Oct 5, 2007 4:37 AM by LeQuoc Thai

    How setup JBoss for the Timeout ?

    LeQuoc Thai Novice

      Hi all!
      I use

      jboss-4.0.5.GA, EJB3.0

      Does Jboss support the timeout if the client (A) was login and he do nothing in a specific time (example 10 minutes), then A will logout automatically?
      Please guide to me or show me some article about my this problem.
      Thank!

      Catania.

        • 1. Re: How setup JBoss for the Timeout ?
          jaikiran pai Master

          Are you looking for the session-timeout of a web-application? If so, you can set it in the web.xml file.

          • 2. Re: How setup JBoss for the Timeout ?
            LeQuoc Thai Novice

            I am looking for the session-timeout ! So, I must configure inside my jboss.xml, am I right ? Can show me a fragment of this problem inside jboss.xml ?

            Thanks very much.

            • 3. Re: How setup JBoss for the Timeout ?
              jaikiran pai Master

               

              "catania" wrote:
              I am looking for the session-timeout ! So, I must configure inside my jboss.xml, am I right ? Can show me a fragment of this problem inside jboss.xml ?

              Thanks very much.


              By default, the session timeout is 30 minutes. If you want to configure this for your application, you can do it in the web.xml file(present in WEB-INF folder of your application). Add the following element at the appropriate place in that file (please check the web.xml dtd http://java.sun.com/dtd/web-app_2_3.dtd for more details):

              <session-config>
               <session-timeout>5</session-timeout>
               </session-config>


              In this example above, i have configured the session-timeout to 5 minutes.


              • 4. Re: How setup JBoss for the Timeout ?
                LeQuoc Thai Novice

                Thanks.

                Oh, sorry! My application is not web-application (my application has two file jboss.xml and ejb-jar.xml and both of them exist inside the META-INF folder).

                So where I configure timeout for my application ?

                Catania.

                • 5. Re: How setup JBoss for the Timeout ?
                  jaikiran pai Master

                   

                  Does Jboss support the timeout if the client (A) was login and he do nothing in a specific time (example 10 minutes), then A will logout automatically?



                  My application is not web-application (my application has two file jboss.xml and ejb-jar.xml and both of them exist inside the META-INF folder).


                  Catania, if your application is not a web-application, can you please explain which login/logout we are talking about? That will help us understand the question better. Also, going by your explanation, i understand that your's is an EJB application. What are the clients to your application? Is it accessed from some web-application or a standalone application or some other EJB or is it from some other client?


                  • 6. Re: How setup JBoss for the Timeout ?
                    LeQuoc Thai Novice

                    My application use DatabaseLoginModule and JAAS.
                    I write a login form (standalone application) to client can enter userName and passWord. And after client login successful, he can call some methods on beans. Example:

                    LoginContext lc = new LoginContext("client", loginForm);
                    lc.login();
                    ...My works here... ---> call some methods on beans
                    lc.logout();

                    My mind is if he login successful, and he do nothing and 10 minutes later, he will logout automatically (same as window system).
                    I thanks for some your relplies, it's very usefull ! Sorry, my E is not good.

                    Expect some guides from you !

                    catania.

                    • 8. Re: How setup JBoss for the Timeout ?
                      LeQuoc Thai Novice

                      Oh, sorry. My purpose is setup the "idle time" for clients.
                      Description:
                      If client A login successful, and if he do nothing (about 10 minutes) - he doesn't call any methods on my beans - he will logout automatically!
                      Have some ideas about my problem.
                      Thanks.

                      • 9. Re: How setup JBoss for the Timeout ?
                        jaikiran pai Master

                         

                        My application use DatabaseLoginModule and JAAS.
                        I write a login form (standalone application) to client can enter userName and passWord. And after client login successful, he can call some methods on beans. My mind is if he login successful, and he do nothing and 10 minutes later, he will logout automatically (same as window system).


                        As far as i know, there's no timeout value that you can specify. However, you can implement your own custom logic for this. May be on the following lines:

                        - Whenever a bean method is called, save the current time (maybe) to a table in database.
                        - Have a timer/scheduled task which regularly checks for the table to see how long the user has been inactive (comparing it against the timeout value).
                        - If you find that there was no activity then call the logout method on the LoginContext as follows:

                        LoginContext lc = new LoginContext("client");
                        lc.logout();


                        Note, that this is just one of the possible approaches i can think of. There might be better options too, depending on the specifics of your application.