tomcat - Jersey servlet 异常 tomcat

标签 tomcat servlets jersey

我正在疯狂地尝试启动一个简单的 Jersey - Spring webapp。我在尝试访问 Web 资源时从 Tomcat 得到的错误是:

HTTP Status 500 -

type Exception report

message

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

exception

javax.servlet.ServletException: Servlet.init() for servlet Jersey Spring Web Application threw exception
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    java.lang.Thread.run(Thread.java:619)

root cause

com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
    com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
    com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391)
    com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:306)
    com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:607)
    com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
    javax.servlet.GenericServlet.init(GenericServlet.java:212)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    java.lang.Thread.run(Thread.java:619)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.28 logs.

我的web.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:application-context.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>Jersey Spring Web Application</servlet-name>
        <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>

        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.companyname.abc</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Jersey Spring Web Application</servlet-name>
        <url-pattern>/webresources/*</url-pattern>
    </servlet-mapping>
</web-app>

知道我做错了什么吗?

最佳答案

我遇到了同样的问题,经过一些调查和 amak 的提示,它与 hbase 依赖性有关,很明显问题是由 HBase 导入 jersey 1.4 引起的,而我在我的项目中使用 jersey 1.10。在排除 HBase 引入的 Jersey 工件之后,一切似乎都很好 atm:

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase</artifactId>
        <version>0.90.4</version>
        <exclusions>
            <exclusion>
                <artifactId>jersey-core</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jersey-json</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jersey-server</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
        </exclusions>
    </dependency>

希望对你有帮助..

关于tomcat - Jersey servlet 异常 tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7450932/

相关文章:

java - 无法启动嵌入式容器 Spring Boot 应用程序 org.apache.catalina.LifecycleException : A child container failed during start

java - 是否有一种容器中立的方式来启用目录列表?

java - 如何在两个 tomcat 服务器之间通信/连接

java - Servlet 映射 Tomcat 错误 Eclipse

java - 以编程方式增加spring boot中的线程数

java - 如何从 OpenStreetMaps API 获取给定地址的坐标

java-8 - 如何将 Java 8 可选与 Moxy 和 Jersey 一起使用

jsp - 带有 MVC 模板和 Tomcat 的 Jersey

rest - WSO2 解耦 Tomcat 和 ESB

java - 在 "ZipFile zipfile = new ZipFile("X 中设置路径 X");"