3 Replies Latest reply on Feb 20, 2012 11:08 AM by jaikiran pai

    JBoss 7.0.2 runs out of threads durring database connection

    varsha g Newbie

      I am using the jsp-servlet in my application. and deployed the war on jboss 7.0.2 server. i have servlet have code related to database and that is being called many time in sec (say 500 times). but it is falling over for such many threads, jboss 7.0.2 will not able to handle this threads. server (jboss7.0.2) throws an exception.

       

       

          java.lang.OutOfMemoryError: unable to create new native thread

           at java.lang.Thread.start0(Native Method)

           at java.lang.Thread.start(Unknown Source)

       

       

      Here is my servlet

       

              public class Test extends HttpServlet {

          private static final long serialVersionUID = 1L;

       

          public Test() {

              super();

          }

       

          protected void doGet(HttpServletRequest request,

                    HttpServletResponse response) throws ServletException, IOException   {

              processRequest(request, response);

          }

       

          protected void doPost(HttpServletRequest request,

                  HttpServletResponse response) throws ServletException, IOException {

              processRequest(request, response);

          }

       

          public void processRequest(HttpServletRequest request,

                  HttpServletResponse response) {

              Logger log=LoggerFactory.getLogger(feedback.class);

              

                 /*   here is my code to insert the data in database. */

       

                      TestClass testobj = new TestClass();       

             

                      testobj.setparam("");

                    

             

              smsmanager1.add(sms);

             

              smsmanager1 = null;

              sms = null;

       

                   

          }

            }

            

      code fot add method

       

             public void add(T obj) {

                   SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

                   Session session=sessionFactory.openSession();

                   Transaction transaction = null;

                   try {

                           transaction = session.beginTransaction();

                           session.save(obj);

                           transaction.commit();

                           session.flush();

                       

                   } catch (HibernateException e) {

                       if(transaction!=null){

                           transaction.rollback();}

                           e.printStackTrace();

                   } finally {

                       if(session!=null){

                           session.close();}

                           session = null;

                           transaction = null;

                   }

       

      i have tested for the blank servlet that has the only one console printing statement. it works fine but it not work for above servlet.

       

      am i on the right track here ?

      how the server will handle the such servlet for above 500-800 threads ?