Resteasy (or not Jersey - JAXRS implementation) on WebLogic12c, is possible?

孤人 提交于 2019-12-08 08:57:25

问题


I have a web application with a restful web service APIs. The application is now developed and works perfectly on Glassfish Server (3.1.x).

As implementation of jax-rs the webapp use Rest-easy, because present features that are no present at Jersey.

Now, it is necessary to deploy the Web application in WebLogic 12c, specifically in weblogic 12.1.2. But it seemed impossible to do so. Weblogic uses Jersey for restful services and gives conflict if it is to use a different implementation jax-rs. Then the question... is it possible to use an implementation of JAX-RS Jersey different. (in my case RestEasy).

Eventhough, the web.xml archive is configured for using the RestEasy Servlet, still show errors like if is used 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>).

The error is:

    <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 (This is the configuration necessary for Resteasy and work in 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>

One of the approach that i try was disabled Jersey on WebLogic. I try with removing jersey libraries used for weblogic in ORACLE_HOME/oracle_common/modules.

  • 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

But i have this error: 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

Edited: Share a little maven project with only one Restful service and configured for using RestEasy. This project work in GF.

Link for download a Maven Project for test de behavior

Can test with de follow URI. GET.

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

 (in glassfish)

回答1:


    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";
   }
...



回答2:


It is possible to deploy RESTeasy and make use of it. Make sure to setup your weblogic.xml correctly so to isolate the classpath. There is no need, and in fact you should not, disable the Jersey module.



来源:https://stackoverflow.com/questions/20641228/resteasy-or-not-jersey-jaxrs-implementation-on-weblogic12c-is-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!