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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]
  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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

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

[hidden email] changed:

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

--- Comment #1 from [hidden email] ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62895

Mark Thomas <[hidden email]> changed:

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

--- Comment #2 from Mark Thomas <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62895

--- Comment #3 from [hidden email] ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62895

--- Comment #4 from [hidden email] ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62895

Christopher Schultz <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]