[英]HTTP Status 500 - Servlet execution threw an exception In tomcat7
I'm trying to retrieve all elements in database and display in webpage.But now it was producing the error HTTP Status 500 - Servlet execution threw an exception
. 我正在尝试检索数据库中的所有元素并在网页中显示。但现在它产生了错误
HTTP Status 500 - Servlet execution threw an exception
。 Can anyone tell me how to fix this error. 任何人都可以告诉我如何解决此错误。 Please help me.
请帮我。
Stack Trace : 堆栈跟踪 :
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: com/google/gson/JsonObject
skypark.RetriveIm.doGet(RetriveIm.java:64)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
java.lang.ClassNotFoundException: com.google.gson.JsonObject
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
skypark.RetriveIm.doGet(RetriveIm.java:64)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
The complete source code is in this question 完整的源代码就在这个问题中
This is the #64
line Gson gson=new Gson();
这是
#64
线Gson gson=new Gson();
Please help me........Thanks.... 请帮帮我........谢谢....
Add library for Gson to you classpath. 将Gson库添加到类路径中。 Either to your webapp (WEB-INF/lib) or to the classpath of your AS.
要么是webapp(WEB-INF / lib),要么是AS的类路径。
You're compiling against the jar providing com.google.gson.JsonObject
(or a dependent) but not deploying it at runtime. 您正在编译提供
com.google.gson.JsonObject
(或从属)但未在运行时部署它的jar。 It needs to be deployed such that that class can be found/loaded by the classloader when run against. 需要对其进行部署,以便在运行时可以由类加载器找到/加载该类。
Assuming your using Eclipse and the project configured as Dynamic Web Project Right click on your project --> choose configure build path
--> now click on add jars button
--> and select the Gson jar
--> click OK
. 假设您使用Eclipse并将项目配置为Dynamic Web Project右键单击您的项目 - >选择
configure build path
- >现在click on add jars button
- >并select the Gson jar
- >单击OK
。
Republish
the project and restart
the server. Republish
项目并restart
服务器。
Else add the jar to WEB-INF\\lib directory
inside the war 否则将jar添加到war
WEB-INF\\lib directory
inside内的WEB-INF\\lib directory
中
Or directly into the Deployed location in the tomcat , but in the same directory as mentioned 或者直接进入tomcat中的Deployed位置,但是在提到的同一目录中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.