您需要执行以下步骤:
通过 JVM 属性 com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true 禁用内置 JAX-RS,请参阅描述 here。
您可以通过 Servers > WebSphere Application Servers > yourServerName 中的 Web 管理控制台设置此属性。然后在Server Infrastructure 部分Java and Process Management > Process definition > Java Virtual Machine > Custom properties。
使用所有 JAX-RS 2.10 库在控制台中通过 Environment > Shared Libraries 创建 isolated 共享库。
创建库时,通过检查Use an isolated class loader for this shared library Class Loading 选项创建隔离共享库。
在安装期间或稍后通过Applications > appName > Shared library references 将此共享库映射到您的应用程序。
重启应用服务器。在 SystemOut.log 中,您应该会看到消息正在初始化 JAX-RS 类:
[7/12/14 16:10:36:470 CEST] 0000004a JerseyServlet I Registering the Jersey servlet application, named javax.ws.rs.core.Application, with the following root resource and provider classes: [class jax.Hello, class org.glassfish.jersey.server.wadl.internal.WadlResource]
[7/12/14 16:10:36:688 CEST] 0000004a ApplicationHa I Initiating Jersey application, version Jersey: 2.10.1 2014-06-30 13:53:32...
更新
似乎也可以从 WAR 中加载 JAX-RS jar。您必须设置此DisableIBMJAXRSEngine 属性,并且需要将模块(不在EAR 级别)类加载器中的类加载选项更改为Classes loaded with local class loader first (parent last)
在管理控制台中:
应用程序 > WebSphere 企业应用程序 > {your.application} > 管理模块 > {your.module}
将类加载器顺序下拉菜单更改为:Classes loaded with local class loader first (parent last)。
感谢 dooffas 的检查,请参阅 JAX-RS 2.0 WebSphere 8.5 without isolated shared library