我有一个带有宁静的Web服务API的Web应用程序。该应用程序现已开发并在Glassfish Server(3.1.x)上完美运行。
作为jax-rs的实现,webapp使用Rest-easy,因为现有的功能在泽西岛没有。
现在,有必要在WebLogic 12c中部署Web应用程序,特别是在weblogic 12.1.2中。 但似乎不可能这样做。 Weblogic使用Jersey来提供宁静的服务,并且如果要使用不同的实现jax-rs则会产生冲突。 那么问题是......是否可以使用不同的JAX-RS Jersey实现。 (在我看来是RestEasy)。
尽管如此,web.xml存档配置为使用RestEasy Servlet,仍然显示错误,如使用泽西(<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库。
但我有这个错误: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服务共享一个maven项目并配置为使用RestEasy。该项目在GF工作。
Link for download a Maven Project for test de behavior
可以使用de follow URI进行测试。 GET。
http://domain:8080/pruebaRestWL/services/test
(in glassfish)
答案 0 :(得分:0)
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";
}
...
答案 1 :(得分:-1)
可以部署RESTeasy并使用它。务必设置weblogic.xml correctly so to isolate the classpath。没有必要,事实上你不应该禁用Jersey模块。