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 2018/11/08 23:04:08 UTC

[Bug 62895] New: load-on-startup of the @WebServlet does not word

https://bz.apache.org/bugzilla/show_bug.cgi?id=62895

            Bug ID: 62895
           Summary: load-on-startup of the @WebServlet  does not word
           Product: Tomcat 9
           Version: 9.0.x
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: richard.gang.li8@gmail.com
  Target Milestone: -----

when i define a load-on-startup Servlet without url-patterns
if I use the web deployment descriptor(web.xml), I can use the below
configuration:
        <servlet>
                <servlet-name>timerServlet</servlet-name>
                <servlet-class>org.crazyit.TimerServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>
the Servlet will be created and init method will be invoked, When i started the
web app.
it means, if i use deploy the loadup-on-startup Servlet with web.xml,
everything is ok.

but, if i use @WebServlet Annotation, loadOnStartup doesnot work.
i use the same Servlet, i don't use the xml configuration,i just use 

@WebServlet(loadOnStartup=1)
init method of the servlet will not be invoked, When i started the web app.
unless i use 
@WebServlet(loadOnStartup=1, urlPatterns={}),
but it does not make senseļ¼Œbecause i don't need any url-pattern for the 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


[Bug 62895] load-on-startup of the @WebServlet does not word

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

richard.gang.li8@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from richard.gang.li8@gmail.com ---
My Servlet is very simple, the Servlet just override the init(ServletConfig)
method

public class TimerServlet extends HttpServlet
{
        public void init(ServletConfig config)throws ServletException
        {
                super.init(config);
                Timer t = new Timer(1000,new ActionListener()
                {
                        public void actionPerformed(ActionEvent e)
                        {
                                System.out.println(new Date());
                        }
                });
                t.start();
        }
}

-- 
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 62895] load-on-startup of the @WebServlet does not word

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

--- Comment #3 from richard.gang.li8@gmail.com ---
OK, I see that
But I have another question, if I use the annotation like that 
@WebServlet(loadOnStartup=1, urlPatterns={}),
it means the Servlet don't have any url pattern, right? But the Servlet still
works, It is still a problem?

-- 
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 62895] load-on-startup of the @WebServlet does not word

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

Mark Thomas <ma...@apache.org> changed:

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

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Servlet specification, version 4, section 8.1.1

<quote>
The annotated servlet MUST specify at least one url pattern to be deployed.
</quote>

No such restriction applies to web.xml.

-- 
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 62895] load-on-startup of the @WebServlet does not word

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

--- Comment #4 from richard.gang.li8@gmail.com ---
I have read the original sentence
<quote>
 The urlPatterns or the value attribute on the annotation MUST be present. 
</quote>

thank you very much

-- 
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 62895] load-on-startup of the @WebServlet does not work

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

Christopher Schultz <ch...@christopherschultz.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|load-on-startup of the      |load-on-startup of the
                   |@WebServlet  does not word  |@WebServlet  does not work

-- 
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