在 Weblogic 12.1.1 上使用 Jersey 2.x Web 服务

2022-01-21 00:00:00 web-services java jax-rs weblogic jersey

我正在尝试将 Jersey 2.13 Web 服务部署到 Weblogic 12.1.1.此版本的 weblogic 符合 JSR-311 JAX-RS 1.1 规范,而 Jersey 2.x 提供 JAX-RS 2.0 的实现

I'm trying to deploy Jersey 2.13 web services to Weblogic 12.1.1. This version of weblogic is compliant with JSR-311 JAX-RS 1.1 specification whereas Jersey 2.x provides implementation for JAX-RS 2.0

Oracle 有关于如何升级 Jersey JAX-RS RI 版本的说明:http://docs.oracle.com/cd/E24329_01/web.1211/e24983/version.htm

Oracle has an instruction on how to upgrade the version of Jersey JAX-RS RI : http://docs.oracle.com/cd/E24329_01/web.1211/e24983/version.htm

然而,即使这样也无助于解决所有的部署问题.

However even this doesn't help solving all of the deployment issues.

我将应用程序打包到包含 WAR 的 EAR 中.为了覆盖 weblogic jar,我添加了以下 weblogic-application.xml 文件:

I'm packaging the application in EAR containing WAR. In order to override weblogic jars I've included added the following weblogic-application.xml file :

<?xml version="1.0" encoding="ISO-8859-1"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
  <prefer-application-packages>
    <!-- apis -->
    <package-name>javax.ws.rs.*</package-name>
    <!-- guava -->
    <package-name>com.google.common.*</package-name>
    <!-- jersey1 providers -->
    <package-name>com.sun.jersey.*</package-name>
    <!-- media providers -->
    <package-name>org.eclipse.persistence.jaxb.rs.*</package-name>
    <package-name>org.codehaus.jackson.jaxrs.*</package-name>
    <!-- wls -->
    <package-name>weblogic.jaxrs.api.client.*</package-name>
    <package-name>weblogic.jaxrs.internal.api.client.*</package-name>
    <package-name>weblogic.jaxrs.dispatch.*</package-name>
    <package-name>weblogic.jaxrs.monitoring.util.*</package-name>

   </prefer-application-packages>
</weblogic-application>

此配置在部署时给我以下错误消息:

This configuration gives me a following error message on deployment :

Caused By: 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;

如果我尝试通过将 org.glassfish.hk2.* 类添加到 prefer-application-packages 来替换它,我会收到新的错误并且它会永远持续下去......

If I try to replace org.glassfish.hk2.* classes by adding it to prefer-application-packages I receive new errors and it's continuing forever...

有人在 weblogic 12.1.1 或更低版本上将 Jersey 迁移到 2.x 版吗?

Has anyone migrated Jersey to version 2.x on weblogic 12.1.1 or below?

谢谢!

推荐答案

最终发现,您实际上必须更换比 Oracle 建议的更多的 jar.这是我的 weblogic-application.xml 的样子:

In the end it turned out that you actually have to replace more jars than Oracle suggests. Here's what my weblogic-application.xml looks like :

 <prefer-application-packages>
    <package-name>com.sun.jersey.*</package-name>
    <package-name>org.glassfish.jersey.*</package-name>
    <package-name>org.glassfish.hk2.*</package-name>
    <package-name>org.jvnet.hk2.*</package-name>
    <package-name>jersey.repackaged.org.objectweb.asm.*</package-name>

    <package-name>com.sun.research.ws.wadl.*</package-name>
    <package-name>com.sun.ws.rs.ext.*</package-name>

    <package-name>org.codehaus.jackson.*</package-name>
    <package-name>com.fasterxml.jackson.*</package-name>

    <package-name>org.codehaus.jettison.*</package-name>

    <package-name>javax.ws.rs.*</package-name>

    <package-name>org.objectweb.asm.*</package-name>

    <package-name>antlr.*</package-name>

  </prefer-application-packages>

希望对你有帮助.

相关文章