java.lang.AbstractMethodError:在将Weblogic升级到12c(12.1.3.0.0)后,在Jersey Rest Webservice上调用

时间:2015-04-02 14:13:30

标签: java rest weblogic jersey-2.0 jersey-client

在我们将Weblogic升级到Weblogic 12C - 12.1.3.0.0之后,使用Jersey Client 2.15调用REST Web服务的应用程序的一部分停止工作。

我们获得的异常跟踪是:

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
    at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
    at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:71)
    at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:185)
    at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:70)

我们确信Jersey和Weblogic WS库之间存在javax.ws.rs不匹配。

依赖关系

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.15</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-common</artifactId>
    <version>2.15</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.4</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.connectors</groupId>
    <artifactId>jersey-apache-connector</artifactId>
    <version>2.15</version>
</dependency>

1 个答案:

答案 0 :(得分:0)

我们不再意识到遵循上述堆栈跟踪的应用程序日志会产生误导。所以我们开始研究Weblogic日志。事实上,域日志确实给出了完全不同的堆栈跟踪:

java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
    at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
    at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:109)
    at org.glassfish.jersey.internal.RuntimeDelegateImpl.<init>(RuntimeDelegateImpl.java:63)
    at 

因此,在进行了一些消防并使用weblogic.xml并打包覆盖后,问题已经排序。以下是实际解决问题的最终包覆盖:

    <wls:package-name>com.sun.jersey.*</wls:package-name>
    <wls:package-name>org.glassfish.jersey.*</wls:package-name>
    <wls:package-name>org.glassfish.hk2.*</wls:package-name>
    <wls:package-name>org.jvnet.hk2.*</wls:package-name>
    <wls:package-name>jersey.repackaged.org.objectweb.asm.*</wls:package-name>
    <wls:package-name>org.objectweb.asm.*</wls:package-name>
    <wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>
    <wls:package-name>javax.ws.rs.*</wls:package-name>