简体   繁体   English

HTTP 状态 500 - servlet 的 Servlet.init() Jersey Web 应用程序抛出异常

[英]HTTP Status 500 - Servlet.init() for servlet Jersey Web Application threw exception

index.html index.html

  <html>
  <body>
   <h2>Jersey RESTful Web Application!</h2>
   <p><a href="webresources/myresource">Jersey resource</a>
    <p>Visit the <a href="http://jersey.java.net">Project Jersey website</a>
    for more information on Jersey!
   </body>
   </html>

MyResource.java我的资源.java

@Path("/myresource")
public class MyResource {

/** Method processing HTTP GET requests, producing "text/plain" MIME media
 * type.
 * @return String that will be send back as a response of type "text/plain".
 */
@GET 
@Produces("text/plain")
public String getIt() {
    return "Hi there!";
}
}

Error is Comming错误来了

  HTTP Status 500 - Servlet.init() for servlet Jersey Web Application threw        exception

 --------------------------------------------------------------------------------

type Exception report

message Servlet.init() for servlet Jersey Web Application threw exception

description The server encountered an internal error that prevented it from      fulfilling this request.

exception 

javax.servlet.ServletException: Servlet.init() for servlet Jersey Web   Application threw exception
     org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
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: com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoaderPA()Ljava/security/PrivilegedAction;
       com.sun.jersey.spi.scanning.AnnotationScannerListener.<init>(AnnotationScannerListener.java:94)
      com.sun.jersey.spi.scanning.PathProviderScannerListener.<init>(PathProviderScannerListener.java:59)
     com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
    com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
    com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
     com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
     com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:696)
     com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674)
     com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:205)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:376)
     com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:559)
     javax.servlet.GenericServlet.init(GenericServlet.java:158)
     org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
     org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
     org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
     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/7.0.67 logs.

you would have use correct version if you want proper output latest version number is 1.19.1 use this try onee如果你想要正确的 output 最新版本号是 1.19.1,你会使用正确的版本使用这个试试

May be problem with servelet api dependcy: use this in your maven pom for exemple: servelet api 依赖性可能有问题:例如,在您的 maven pom 中使用它:

   <!-- servlet api 3 -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>

Its seems a java version issue.它似乎是一个 java 版本问题。 compile the code with supporting jar(java version) only仅使用支持的 jar(java 版本)编译代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTTP 状态 500 - servlet Jersey Web 应用程序的 Servlet.init() 抛出异常 REST Web 服务错误 - HTTP Status 500 - Servlet.init() for servlet Jersey Web Application threw exception REST web-service error HTTP状态500-Servlet球衣的Servlet.init()-Servlet抛出异常 - HTTP Status 500 - Servlet.init() for servlet jersey -servlet threw exception HTTP 状态 500 - servlet appServlet 的 Servlet.init() 抛出异常 - HTTP Status 500 - Servlet.init() for servlet appServlet threw exception HTTP状态500-Servlet Dispatcher的Servlet.init()抛出异常 - HTTP Status 500 - Servlet.init() for servlet Dispatcher threw exception HTTP状态500-Servlet HelloWeb的Servlet.init()抛出异常? - HTTP Status 500 - Servlet.init() for servlet HelloWeb threw exception? HTTP状态500 - servlet fitTrackerServlet的Servlet.init()引发异常 - HTTP Status 500 - Servlet.init() for servlet fitTrackerServlet threw exception HTTP状态500-Servlet appServlet的Servlet.init()抛出异常 - HTTP Status 500 - Servlet.init() for servlet appServlet threw exception “ HTTP状态500-Servlet的Servlet.init()引发了异常” - “HTTP Status 500 - Servlet.init() for servlet spring threw exception” HTTP状态500-Servlet球衣-serlvet的Servlet.init()抛出异常? - HTTP Status 500 - Servlet.init() for servlet jersey-serlvet threw exception? 如何修复 HTTP 状态 500 - Servlet.init() for servlet jersey 抛出异常? - How can I fix HTTP Status 500 - Servlet.init() for servlet jersey threw exception?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM