泽西servlet异常tomcat

发布于 2024-12-04 21:58:10 字数 3787 浏览 1 评论 0原文

我正在疯狂地尝试启动一个简单的 Jersey - Spring Web 应用程序。我在尝试访问 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>

你知道我做错了什么吗?

Am going nuts trying to start up a simple Jersey - Spring webapp. The error I get from Tomcat upon trying to access the web resources is:

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.

My web.xml is as follows:

<?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>

Any ideas what I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

魂ガ小子 2024-12-11 21:58:10

我遇到了同样的问题,经过一番调查和 amak 的提示,它与 hbase 依赖性有关,很明显,问题是由 HBase 导入 jersey 1.4 而引起的,而我在项目中使用 jersey 1.10。在排除 HBase 拉入的球衣工件后,一切似乎都很好 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>

希望有帮助..

I had the same problem and after some investigation and amak's tip that it had something to do with the hbase dependency it became clear that the problem was caused by HBase importing jersey 1.4 while i was using jersey 1.10 in my project. After excluding the jersey artifacts pulled in by HBase everything seems fine 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>

hope that helps..

梦在夏天 2024-12-11 21:58:10

如果您只是想让一个基本示例正常工作,那么这种情况不应该发生。也许您有一个损坏的球衣服务器 jar。尝试删除现有的并下载新的。

此错误意味着您的 jar 缺少文件 META-INF/services/com.sun.jersey.spi.container.WebApplicationProvider,该文件告诉它要使用哪个 WebApplicationProvider。

If you're just trying to get a basic example working, that shouldn't happen. Maybe you have a corrupt jersey-server jar. Try deleting your existing one and downloading a new one.

This error implies that your jar is missing the file META-INF/services/com.sun.jersey.spi.container.WebApplicationProvider, which tells it which WebApplicationProvider to use.

花桑 2024-12-11 21:58:10

在我的例子中,

mvn dependency:tree

显示我使用了另一个版本的 jersey-server 。我包含版本 1.12,但在树中出现

com.sun.jersey:jersey-server:jar:1.9-ea07:编译

修复这个奇怪的依赖关系后,错误消失了。

In my case

mvn dependency:tree

showed my that another version of jersey-server was used. I was including version 1.12, but in the tree appeared

com.sun.jersey:jersey-server:jar:1.9-ea07:compile

After fixing this weird dependency the error was gone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文