美文网首页
Caused by: javax.ws.rs.Processin

Caused by: javax.ws.rs.Processin

作者: 空尘AI | 来源:发表于2020-06-12 10:31 被阅读0次
    Caused by: javax.ws.rs.ProcessingException: javax.ws.rs.core.ResponseStatusFamily.familyOf(I)Ljavax/ws/rs/core/ResponseStatusFamily;报错解决

    问题如下:
    项目中用到了hugegraph和eureka,打包以后直接运行jar包没问题,将jar包解压后用脚本直接启动SpringBootApplication的时候报错如下:


    image.png

    上面截图看不清楚的话可以看下面这段

    Caused by: com.baidu.hugegraph.rest.ClientException: Failed to do request
        at com.baidu.hugegraph.rest.RestClient.request(RestClient.java:128)
        at com.baidu.hugegraph.rest.RestClient.get(RestClient.java:190)
        at com.baidu.hugegraph.api.version.VersionAPI.get(VersionAPI.java:41)
        at com.baidu.hugegraph.driver.VersionManager.getApiVersion(VersionManager.java:45)
        at com.baidu.hugegraph.driver.HugeClient.checkServerApiVersion(HugeClient.java:122)
        at com.baidu.hugegraph.driver.HugeClient.initManagers(HugeClient.java:108)
        at com.baidu.hugegraph.driver.HugeClient.<init>(HugeClient.java:72)
        at com.baidu.hugegraph.driver.HugeClient.<init>(HugeClient.java:60)
        at com.ronglian.service.OPService.<clinit>(OPService.java:68)
        ... 37 common frames omitted
    Caused by: javax.ws.rs.ProcessingException: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:261)
        at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
        at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:411)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:311)
        at com.baidu.hugegraph.rest.RestClient.lambda$get$3(RestClient.java:191)
        at com.baidu.hugegraph.rest.RestClient.request(RestClient.java:126)
        ... 45 common frames omitted
    Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
        at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:63)
        at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:54)
        at org.glassfish.jersey.message.internal.Statuses.from(Statuses.java:143)
        at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:440)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
        ... 56 common frames omitted
    

    在引入eureka-client坐标之前是没有报错信息的,因此可以确定是eureka包引发的冲突,相比其他子工程该pom中引入了一个新的坐标hugegraph-client,由此可推断就是下面这两个坐标中继承过来的坐标有冲突:

            <dependency>
                <groupId>com.baidu.hugegraph</groupId>
                <artifactId>hugegraph-client</artifactId>
                <version>1.8.0</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
                <version>1.4.1.RELEASE</version>
            </dependency>
    

    解决办法是排除掉eureka-client中的jsr311-api依赖:

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
                <version>1.4.1.RELEASE</version>
                <exclusions>
                    <!-- Causes java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family; -->
                    <exclusion>
                        <groupId>javax.ws.rs</groupId>
                        <artifactId>jsr311-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    

    问题完美解决,在此做个笔记。

    相关文章

      网友评论

          本文标题:Caused by: javax.ws.rs.Processin

          本文链接:https://www.haomeiwen.com/subject/tmcgtktx.html