Servlet program http Status 500-error instantiating servlet class resolution

Source: Internet
Author: User
Tags tomcat tomcat server

Questions:

1. Tomcat can start normally in eclipse, while access to http://localhost:8080/in the browser is not accessible and is reported as 404 error. Other project pages cannot be accessed at the same time.

Close the tomcat inside Eclipse, double-click Startup.bat in the Tomcat installation directory to manually start the Tomcat server. Access htt://localhost:8080/can access the Tomcat administration page normally.

Cause: Eclipse redirects the Tomcat Project publishing directory (WebApp in the Tomcat directory), so you will find that your project file is not found in the WebApp directory under the Tomcat installation directory.

Workaround

Reconfigure the following Tomcat server:

On the server page in Eclipse, double-click the Tomcat service and you will see the configuration page as shown in the figure:


You can see that the red circle is selected with the Use workspace metadata (does not modify Tomcat installion)

If a project is deployed in this tomcat, the options in the red circle will be grayed out and cannot be modified, and the modifications must first be removed from the deployed service in Tomcat.

By right-clicking the Tomcat server, select Add and remove to remove the deployed project in the popup dialog box. When you are finished removing the OK, you will see the Options Panel section above editable. If it's still gray , right-click Tomcat in the servlet


Select the Use Tomcat installation (Task control of Tomcat installation) to select Tomcat's installation directory as the publishing directory for the project.
Then, down four lines, see "Deploy Path"? The value behind it defaults to "Wtpwebapps", which is changed to "WebApps", which is Tomcat
The name of the folder in which the item is published.

Or


After modification, turn off the page and save the configuration. This deploys the project to the WebApp in the Tomcat installation directory
Restart the Tomcat server, access to the http://localhost:8080 will be able to access the normal, your own deployment of the project is also able to access.


2. compile the servlet in Eclipase but consistently report the HTTP Status 500-error instantiating the servlet class XXX class,

Workaround 1. Detection in Web. XML <servlet><servlet-mapping> There is no configuration error 2.  Check the project under the build\classes there is no Xxx.class file for you, or Tomcat WebApps under the Xxx.class file that has not been well compiled 3. The Servlet class also configures and adds @webservlet annotations to Web. XML, removing one of them to 4. Tomcat did not successfully deploy the project to check if the servlet was initialized, that is, to output a log or breakpoint in the Init method to see if it entered

5. Look in the Eclipse tool: Project->build automatically this option, whether it is checked, if not checked, if selected, Eclipse can be compiled automatically, after compiling there will be a class

the lesson of blood.

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.