gpt4 book ai didi

java - WebLogic 12c 中的 Resteasy(或不是 Jersey - JAX RS 实现)可能吗?

转载 作者:太空宇宙 更新时间:2023-11-04 15:18:42 25 4
gpt4 key购买 nike

我有一个带有 Restful Web 服务 API 的 Web 应用程序。该应用程序现已开发并可在 Glassfish Server (3.1.x) 上完美运行。

作为 jax-rs 的实现,Web 应用程序使用 Rest-easy,因为它提供了 Jersey 中不存在的功能。

现在,需要在 WebLogic 12c 中部署 Web 应用程序,特别是在 weblogic 12.1.2 中。但这似乎是不可能的。 Weblogic 使用 Jersey 提供静态服务,如果使用不同的实现 jax-rs 则会产生冲突。那么问题...是否可以使用不同的 JAX-RS Jersey 实现。 (在我的例子中 RestEasy)。

尽管 web.xml 存档配置为使用 RestEasy Servlet,但仍然显示错误,例如 if isused Jersey ( <BEA-101216> <Servlet: "Jersey" failed to preload on startup in Web application: "pruebaRestWL-1.0-SNAPSHOT") and ( <Error> com.sun.jersey.spi.inject.Errors> )。

错误是:

    <17/12/2013 10:52:07 AM CST> <Warning> <weblogic.jaxrs.server.portable.servlet.ServletContainer> <BEA-000000> <Failed to create monitoring factory: oracle.j2ee.ws.server.jaxrs.dms.JaxRsDMSMonitoringEventReceiverFactory:
oracle.j2ee.ws.server.jaxrs.dms.JaxRsDMSMonitoringEventReceiverFactory>
<17/12/2013 10:52:08 AM CST> <Error> <com.sun.jersey.spi.inject.Errors> <BEA-000000>
<The following errors and warnings have been detected with resource and/or provider classes: SEVERE:
Missing dependency for constructor public org.jboss.resteasy.plugins.providers.DocumentProvider(org.jboss.resteasy.spi.ResteasyConfiguration) at parameter index 0
SEVERE: Missing dependency for constructor public org.jboss.resteasy.core.AsynchronousDispatcher(org.jboss.resteasy.spi.ResteasyProviderFactory) at parameter index 0>
<17/12/2013 10:52:08 AM CST> <Error> <HTTP> <BEA-101216> <Servlet: "Jersey" failed to preload on startup in Web application: "pruebaRestWL-1.0-SNAPSHOT".
com.sun.jersey.spi.inject.Errors$ErrorMessagesException at
com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) at
com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) at
com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765) Truncated. see log file for complete stacktrace

web.xml(这是Resteasy和在GF中工作所需的配置)

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- :::::::::::::::::::::::::::::::::::::: -->
<!-- Configuración para implementación rest -->
<!-- :::::::::::::::::::::::::::::::::::::: -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name> <!-- Servlet for use RestEasy -->
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/services</param-value>
</context-param>
</web-app>

我尝试的方法之一是在 WebLogic 上禁用 Jersey。我尝试删除 ORACLE_HOME/oracle_common/modules 中用于 weblogic 的 jersey 库。

  • jersey-client-1.17.1
  • jersey-core-1.17.1
  • jersey-json-1.17.1
  • jersey-multipart-1.17.1
  • jersey-server-1.17.1
  • jersey-servlet-1.17.1

但我有这个错误:weblogic.application.ModuleException:java.lang.ArrayStoreException:sun.reflect.annotation.TypeNotPresentExceptionProxy

<17/12/2013 10:07:15 AM CST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1387296431330" for task "0". Error is: "weblogic.application.ModuleException: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy"
weblogic.application.ModuleException: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:213)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:208)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace

编辑:共享一个只有一个 Restful 服务并配置为使用 RestEasy 的小型 Maven 项目。该项目在GF工作。

Link for download a Maven Project for test de behavior

可以使用 de follow URI 进行测试。获取。

 http://domain:8080/pruebaRestWL/services/test

(in glassfish)

最佳答案

    Here is working solution on WebLogic 12.2.1 and WebLogic 10.3.6

Changes in pom.xml
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.2.1.GA</version>
</dependency>

Changes in web.xml
<!-- A comma delimited list of fully qualified JAX-RS resource class names you want to register -->
<!-- And don't use resteasy.scan=true -->
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>com.***.RestServiceClass</param-value>
</context-param>

<!-- This is needed if the url-pattern for the Resteasy servlet-mapping is not /* -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>

<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>

<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>

@Stateless
@Path("/test")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class RestServiceClass
{
@POST
@Path("/doJob1")
@GZIP
public String doJob1()
{
return "Ok";
}
...

关于java - WebLogic 12c 中的 Resteasy(或不是 Jersey - JAX RS 实现)可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20641228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com