Status 500 error instantiating servlet class in Tomcat

huangapple go评论77阅读模式
英文:

Status 500 error instantiating servlet class in Tomcat

问题

I was executing a web project and it is throwing an error 500 error instatiating servlet class .
我正在执行一个Web项目,但它抛出了一个错误500错误,实例化Servlet类。

I am using tomcat 9.0.71 and using web module 4.0 .
我使用的是Tomcat 9.0.71,并且使用Web模块4.0。

This is the error message on the screen.
这是屏幕上的错误消息。

This is the error page status 500

This is the html document
这是HTML文档

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>This is a hello world</h1>
<br>
<form action="hello" method="get">
<input type="submit">click to say hello world
</form>
</body>
</html>

This is the servlet class
这是Servlet类

package ronit;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.*;
@WebServlet("/hello")
class hello extends HttpServlet{
 static final long serialVersionUID = 35335L;
public void doGet(HttpServletRequest req, HttpServletResponse res) {

try {
PrintWriter p = res.getWriter();

p.println("Hello World");
}catch(IOException e) {e.printStackTrace();}
}}

This is the deployment configuration in the server
这是服务器中的部署配置

This is the servlet view

This is the console after execution

This is the project explorer view

I am using annotations instead of web.xml and deploying the file by right clicking on the project and run on server .
我使用注解而不是web.xml,并通过右键单击项目并在服务器上运行来部署文件。

Please consider telling me if more details required on question
如果需要更多细节,请告诉我。

英文:

I was executing a web project and it is throwing an error 500 error instatiating servlet class .
I am using tomcat 9.0.71 and using web module 4.0 .

This is the error message on the screen.

This is the error page status 500

This is the html document

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;This is a hello world&lt;/h1&gt;
&lt;br&gt;
&lt;form action =&quot;hello&quot; method=&quot;get&quot;&gt;
&lt;input type=&quot;submit&quot;&gt;click to say hello world
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

This is the servlet class

package ronit;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.*;
@WebServlet(&quot;/hello&quot;)
class hello extends HttpServlet{
 static final long serialVersionUID = 35335L;
public void doGet(HttpServletRequest req, HttpServletResponse res) {

try {
PrintWriter p = res.getWriter();

p.println(&quot;Hello World&quot;);
}catch(IOException e) {e.printStackTrace();}
}}


This is the deployment configuration in the server

This is the servlet view

This is the console after execution

This is the project explorer view

I am using annotations instead of web.xml and deploying the file by right clicking on the project and run on server .

Please consider telling me if more details required on question

答案1

得分: 0

Your servlet class has no public, zero argument, constructor. It needs one, otherwise Tomcat can not instantiate it--exactly as the error output is telling you.

英文:

Your servlet class has no public, zero argument, constructor. It needs one, otherwise Tomcat can not instantiate it--exactly as the error output is telling you.

huangapple
  • 本文由 发表于 2023年5月13日 21:48:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243059.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定