Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-4848

Undertow does not call the init() method of servlets that implements SingleThreadModel even when load-on-startup is set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.1.CR2, 7.0.1.GA
    • None
    • Undertow
    • None
    • EAP 7.0.1

      Found that some of the servlets did not have the init() invoked on start up. Found that if the servlet implements javax.servlet.SingleThreadModel, their init() methods are not called.

      Sample snippnet from web.xml

      	<servlet>
      		<servlet-name>testServlet</servlet-name>
      		<servlet-class>TestServlet</servlet-class>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      

      Sample servlet

      @Slf4j
      public class TestServlet extends HttpServlet implements SingleThreadModel {
      
      	@Override
      	public void init(ServletConfig config) throws ServletException {
      		log.info("init() in TestServlet");
      		super.init(config);
      	}
      
      	@Override
      	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      		log.info("doGet() in TestServlet");
      	}
      
      	@Override
      	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      		log.info("doPost() in TestServlet");
      	}
      }
      

      If the servlet does not implements SingleThreadModel , the init() method is called on start up.

            sdouglas1@redhat.com Stuart Douglas
            lamshing Shing Lam (Inactive)
            Jan Stourac Jan Stourac
            Jan Stourac Jan Stourac
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: