Java apache tomcat 服务器上的 500 内部服务器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38038188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
500 Internal server error on apache tomcat server
提问by M.Movaffagh
i have a war
file and i deployed it on my first server. every thing is okay there.
you can test it on http://185.126.201.83:10808/crmapi/rest/v1/authentication/hi(port is different because it is behind a firewall)
but in my new server i get below error and everything are same in both server. what is wrong?
you can test it on : http://185.21.76.71:8080/crmapi/rest/v1/authentication/hi
我有一个war
文件,我将它部署在我的第一台服务器上。那里的一切都很好。您可以在http://185.126.201.83:10808/crmapi/rest/v1/authentication/hi 上对其进行测试
(端口不同,因为它位于防火墙后面)但在我的新服务器中,我遇到以下错误并且两者都相同服务器。怎么了?你可以测试它:http: //185.21.76.71: 8080/crmapi/rest/v1/authentication/hi
type Exception report
message Servlet.init() for servlet com.crmapi.services.ApplicationConfig threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet com.crmapi.services.ApplicationConfig threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:309)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:315)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.36 logs.
ubuntu 16.04 Server x64 and Apache Tomcat/8.0.36
ubuntu 16.04 服务器 x64 和 Apache Tomcat/8.0.36
回答by Andrew Lygin
It looks that the JRE versions differ on your servers.
看起来 JRE 版本在您的服务器上有所不同。
回答by Chaturvedi Saurabh
Apache Tomcat stack trace tells it all .Your issue is definitely having multiple JAX-RS jars in the classpath of your application. It looks like javax.ws.rs.core.Application class is loaded from some Jar but it doesn't have the getProperties() method that returns a Java.util.Map . You need to strictly check presence of duplicate jars .If you are not able to find it manually , you can use a tool like JHade to detect presence of duplicate jars .But if you are too sure that application class path has only one JAX-RS jar , please inspect carefully whether it has the required getProperties() method or not in the javax.ws.rs.core.Application class. If you debug your code on these lines, you may end up with a solution. Let me know if that helps you :) . PS - JAX RS 1.x jars do not have getProperties() method but JAX-RS 2.x have .
Apache Tomcat 堆栈跟踪说明了一切。您的问题肯定是在您的应用程序的类路径中有多个 JAX-RS jar。看起来 javax.ws.rs.core.Application 类是从某个 Jar 加载的,但它没有返回 Java.util.Map 的 getProperties() 方法。您需要严格检查是否存在重复的 jar。如果您无法手动找到它,您可以使用 JHade 之类的工具来检测是否存在重复的 jar。但是如果您太确定应用程序类路径只有一个 JAX-RS jar ,请仔细检查它在 javax.ws.rs.core.Application 类中是否具有所需的 getProperties() 方法。如果您在这些行上调试代码,您最终可能会得到一个解决方案。如果这对您有帮助,请告诉我:)。PS - JAX RS 1.x jar 没有 getProperties() 方法,但 JAX-RS 2.x 有 .
回答by Riddhi Sanyal
Looks like you have jar mismatch of JAX-RS versions. Use maven to control your JAX-RS version. If you are using jersey, use 2.23.2 or more versions.
看起来您的 JAX-RS 版本的 jar 不匹配。使用 maven 控制您的 JAX-RS 版本。如果您使用球衣,请使用 2.23.2 或更高版本。
You can check your successful deployment via http://185.21.76.71:8080/crmapi/application.wadl
您可以通过http://185.21.76.71:8080/crmapi/application.wadl检查您的成功部署
回答by Pranjal Soni
One of the other error that we are possibly do that we are not declaring our servlet
class as public
This thing we need to remember because servlet
container always looks for servlet
class in public area so our servlet
file must be public
Otherwise we will get
Error 500- internal server error.
我们可能会犯的另一个错误之一是我们没有将我们的servlet
类声明为public
我们需要记住的事情,因为servlet
容器总是servlet
在公共区域中查找类,因此我们的servlet
文件必须是公共的,否则我们将收到错误 500-内部服务器错误。