6 Replies Latest reply on Mar 2, 2008 10:41 AM by Sen

    Can "NestedSQLException" be counted in the J2EE application?

    Sen Newbie

      Hi everyone,

      I am using JBoss AS 4.0.5 + MySQL. And I am trying to test the perfomance of my J2EE application under very high workload. Sometimes the standard console will printout:

      "org.jboss.util.NestedSQLException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))"

      I know this is because my system runs out of ManagedConnections, which means I probably need to increase the "max-pool-size". My question is if there is any way I can count how many times this exception is thrown inside my J2EE application?

      That is, is there any MBean or any other things record the number of times JBoss throws an exception so that my program can access to determine it got a problem. Hope I explain my question clearly.

      Thank you

        • 1. Re: Can
          jaikiran pai Master

           

          My question is if there is any way I can count how many times this exception is thrown inside my J2EE application?


          Why would you want to know "how many times" this exception was thrown?


          • 2. Re: Can
            Sen Newbie

            Because I am working on self-adaptive system. If too many exceptions are thrown, I hope the system can self-adapt to solve the problem by itself.

            • 3. Re: Can
              Vicky Kak Master

               

              "vola" wrote:
              Because I am working on self-adaptive system. If too many exceptions are thrown, I hope the system can self-adapt to solve the problem by itself.


              Theoritically there can be couple of ways which comes to my mind , but don't do it unless there is not workaround
              1) Modify the InternalManagedConnectionPool , have the variable in the Counter which will should be updated here .
              else
               {
               // UPDATE THE COUNTER HERE
               // we timed out
               throw new ResourceException("No ManagedConnections available within configured blocking timeout ( "
               + poolParams.blockingTimeout + " [ms] )");
               }

              In the InternalManagedConnectionPool$Counter keep getFailedCount()/setFailedCount methods , these should again be exposed through the JbossManagedConnectionPool .
              This is trivial change in
              http://anonsvn.jboss.org/repos/jbossas/trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
              http://anonsvn.jboss.org/repos/jbossas/trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java

              2) Have a Mbean which will scan the server.log file and check for the occurance of the NoManagedConnection Error .
              Or you can direct the error logging to a specific log file , the Mbean will use this log file and change the setting of the Pool on the fly .

              But DON't try these options , you should identify the peak load to which pool can be subjected and configure max pool size accordingly .
              The pool will shrink if these connections are not used over long time which is configurable (idle-timeout-minutes) , so keeping the high value for the pool will not be the issue , the pool implementation will take care of all .





              • 4. Re: Can
                Vicky Kak Master

                Another option :
                You can keep count of NoManagedConnection error in the application code.
                Finally have a custom MBean which will get this count from the application code and then set the min./max pool size on the JbossManagedConnectionPoolMBean .

                • 5. Re: Can
                  Adrian Brock Master

                  Sounds like a job for aop to me?

                  • 6. Re: Can
                    Sen Newbie

                    Ok. Thanks alot for your advice. I will try these. ^^