REST Jersey中的例外情况 [英] Exception in REST Jersey

查看:185
本文介绍了REST Jersey中的例外情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试启动应用程序,但使用 Tomcat 7 ,我有一个这样的例外。

I try to start application but using Tomcat 7 and I've got an exception like this.

我认为这可能是 Maven依赖,但我确定。如果有人知道发生了什么,请回答:)

I think this can be something with Maven dependency, but I'm sure. If some know what is going on please for answer:)

例外:

message Servlet execution threw an exception

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

exception

javax.servlet.ServletException: Servlet execution threw an exception
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
    javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:651)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.50 logs.

Maven POM

<properties>
        <application.version>1.0</application.version>
        <spring.version>4.0.0.RELEASE</spring.version>
        <spring.security.version>3.2.0.RELEASE</spring.security.version>
        <jersey.version>1.18.1</jersey.version>
    </properties>



    <dependencies>
        <dependency>
            <groupId>climbing-portal-facade</groupId>
            <artifactId>climbing-portal-facade</artifactId>
            <version>${application.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
            <artifactId>jersey-test-framework-provider-jdk-http</artifactId>
            <version>2.7</version>
        </dependency>

        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>${jersey.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aop</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>

有什么想法吗?

推荐答案

你正在使用 Jersey 1& 2 (Jersey 1是显式依赖项,Jersey 2是 jersey-test-framework-provider-jdk-http 的传递依赖项),这是不可能 - 所以类加载器正在选择错误的 URIBuilder 类。

You're using both Jersey 1 & 2 (Jersey 1 is an explicit dependency, Jersey 2 is a transitive dependency of jersey-test-framework-provider-jdk-http) and that's not possible - so the classloader is picking up the wrong URIBuilder class.

组中的 Jersey 依赖项 com.sun.jersey 都是 Jersey版本1
Jersey版本2 使用组 org.glassfish.jersey

The Jersey dependencies in group com.sun.jersey are all Jersey version 1. Jersey version 2 uses the group org.glassfish.jersey.

您的 Maven 依赖项中都存在导致此问题的依赖项。

You have both in your Maven dependencies which is causing this problem.

如果可能,只使用 Jersey 2

这篇关于REST Jersey中的例外情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆