JBoss AS 7.0.2 runs out of threads during database

2019-06-08 00:30发布

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;

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(Test.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 for 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?

0条回答
登录 后发表回答