You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/04/18 09:54:48 UTC

[Bug 56426] New: load -on-startup creating instance to servlet twice

https://issues.apache.org/bugzilla/show_bug.cgi?id=56426

            Bug ID: 56426
           Summary: load -on-startup creating instance to servlet twice
           Product: Tomcat 7
           Version: trunk
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet & JSP API
          Assignee: dev@tomcat.apache.org
          Reporter: sridhar.a@headinfotech.com

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ace2three.adminportal.web;

import com.ace2three.web.dao.CommonDAO;
import com.ace2three.platform.server.impl.ApplicationContext;
import com.ace2three.pool.DAOFactory;
import com.ace2three.utils.LeaderBoardThread;
import com.ace2three.web.dao.AdminToolDAO;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.Logger;

/**
 *
 * @author sridhar
 */
public class LoadConfig extends HttpServlet {
     private static Logger log = Logger.getLogger(LoadConfig.class);
     private boolean alreadyInitialized = true;
    public void init(ServletContext context) throws ServletException {
  // TODO Auto-generated method stub 
        ServletConfig config = null;
        super.init(config);
  //-Dlog4j.configuration=file:D:\acc_config\log4j.xml
        if (this.alreadyInitialized)
        {
        try {

                new LeaderBoardThread().start();

        } catch (Exception e) {
             log.info("Exception in loadConfig :: "+e);
            e.printStackTrace();
        }
        this.alreadyInitialized = false;
        }

 }
    @Override
    public void destroy() {
        log.info( "Destroy called", new Throwable() );
        super.destroy();
        this.alreadyInitialized = false;
    }
    /*@Override
    public void init( ServletConfig config )
        throws ServletException
    {
        log.info( "Init called, config="+config, new Throwable() );
        super.init( config );
        if (this.alreadyInitialized)
        {
            log.error( "Already initialized");
            throw new IllegalStateException( "Already initialized" );
        }
        this.alreadyInitialized = true;
    }*/
}

LeaderBoardThread: ******** Calling leader board Therad ******************
708770251
LeaderBoardThread: ******** Calling leader board Therad ******************
1200582472

here am getting two thread process for every tomcat restart please check
hash codes also here for therad process

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56426] load -on-startup creating instance to servlet twice

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56426

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID
                 OS|                            |All

--- Comment #1 from Konstantin Kolinko <kn...@gmail.com> ---
Bugzilla is not a support forum.

Judging from quality of your code (typos, inverted meaning of 'already', etc.)
I guess that you are doing something stupid. If you need help with
troubleshooting, see
http://tomcat.apache.org/findhelp.html

If you want something to be initialized once, you should use a listener, not a
servlet.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org