Server Tomcat v7.0 server at localhost failed to start. Temporary solution

Source: Internet
Author: User

Error Name: Server Tomcat v7.0 server at localhost failed to start.

Workaround: Remove the following sentence:

(usually at the beginning of the code, before the public class)

1 @WebServlet ("/twoservlet")

"/twoservlet" a similar name

@WebServlet What the hell is this thing?

After you've written the servlet, let's tell the Web container some information about the servlet. In Servlet 3.0, you can use annotations (Annotation) to tell the container which servlets provide services and additional information. For example, in Helloservlet.java:

1 @WebServlet ("/hello.view")2publicclassextends HttpServlet {


As long as the @webservlet annotation is set on the servlet, the container will automatically read the information in it. The above @webservlet tells the container that if the requested URL is "/hello.view", the service is provided by the instance of HelloServlet. You can use @webservlet to provide more information.

1 @WebServlet (2 name= "Hello",3 urlpatterns={"/hello.view"},4 Loadonstartup=15)6publicclassextends httpservlet {


The above @webservlet informs the container that the name of the servlet helloservlet is Hello, which is specified by the Name property, and if the URL requested by the client is/ Hello.view, it is handled by a servlet with the Hello name, which is specified by the Urlpatterns property. When using annotations in Java EE-related applications, you can remember that properties that are not set usually have default values. For example, if you do not set the Name property of @webservlet, the default value is the full name of the servlet's class.


When the application starts, it does not actually create all the servlet instances. The container instantiates the corresponding servlet class, initializes it, and then processes the request when it first requests a servlet service. This means that the client requesting the servlet for the first time must wait for the servlet class to instantiate, and the initial action must take time to actually get the requested processing.


If you want the application to start by loading, instantiating, and initializing the servlet class first, you can use the Loadonstartup setting. Setting a value greater than 0 (the default is-1) means that the servlet is initialized when the application is started (instead of instantiating several servlets). The number represents the initial order of the servlet, and the container must ensure that a servlet with a smaller number is initialized first, and that if more than one servlet uses the same number when setting loadonstartup, using annotations The container implementation vendor can decide for itself which servlet to load.

Server Tomcat v7.0 server at localhost failed to start. Temporary solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.