Weblogic Resteasy部署问题

时间:2014-03-20 12:09:40

标签: java weblogic resteasy weblogic12c

我有一个与Resteasy合作的项目,我尝试使用Web控制台将其部署到Weblogic 12.1.1.0中。所有与Resteasy相关的罐子都是手动添加的,它不是一个maven项目。

我删除了每个使用Resteasy的类,并删除了web.xml中与Resteasy相关的所有行,但它抛出异常。即使我在我的项目中不使用Resteasy,它也会抛出异常。如果Resteasy罐子在我的项目中,则Weblogic不会部署它。

我得到的例外是:

weblogic.j2ee.dd.xml.AnnotationProcessException: [HTTP:101396]The urlPatterns or the value attribute on the WebServlet annotation MUST be present: org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher.
    at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1615)
    at weblogic.servlet.internal.WebAnnotationProcessor.validateValueAndUrlPatterns(WebAnnotationProcessor.java:175)
    at weblogic.servlet.internal.WebAnnotationProcessor.processWebServletAnnotation(WebAnnotationProcessor.java:131)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:162)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:116)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:143)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:104)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:81)
    at weblogic.servlet.internal.WebAppModule.processAnnotations(WebAppModule.java:1828)
    at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:717)
    at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:188)
    at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:83)
    at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:172)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:167)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
    at weblogic.application.internal.flow.ModuleStateDriver.prepare(ModuleStateDriver.java:38)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:139)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:55)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
    at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

and

weblogic.j2ee.dd.xml.AnnotationProcessException: [HTTP:101397]The urlPatterns attribute, servletNames attribute or the value attribute of the WebFilter annotation MUST be specified: org.jboss.resteasy.plugins.server.servlet.Filter30Dispatcher.
    at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1615)
    at weblogic.servlet.internal.WebAnnotationProcessor.validateValueAndUrlPatterns(WebAnnotationProcessor.java:192)
    at weblogic.servlet.internal.WebAnnotationProcessor.processWebFilterAnnotation(WebAnnotationProcessor.java:205)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:165)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:116)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:143)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:104)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:81)
    at weblogic.servlet.internal.WebAppModule.processAnnotations(WebAppModule.java:1828)
    at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:717)
    at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:188)
    at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:83)
    at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:172)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:167)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
    at weblogic.application.internal.flow.ModuleStateDriver.prepare(ModuleStateDriver.java:38)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:139)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:55)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
    at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)


    at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1614)
    at weblogic.servlet.internal.WebAnnotationProcessor.validateValueAndUrlPatterns(WebAnnotationProcessor.java:175)
    at weblogic.servlet.internal.WebAnnotationProcessor.processWebServletAnnotation(WebAnnotationProcessor.java:131)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:162)
    at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:116)
    Truncated. see log file for complete stacktrace
> 

这是我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <display-name></display-name>
  <filter>
    <filter-name>CORSFilter</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
    <init-param>
      <param-name>cors.allowOrigin</param-name>
      <param-value>*</param-value>
    </init-param>
    <init-param>
      <param-name>cors.supportedHeaders</param-name>
      <param-value>X-Requested-With, Content-Type, Origin, Accept</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>CORSFilter</filter-name>
    <servlet-name>Resteasy</servlet-name>
  </filter-mapping>

  <servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
    <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>com.maozturk.rest.RestServices</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/upload/*</url-pattern>
  </servlet-mapping>

  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>
</web-app>

我班上的第一行如下:

@Path( "/upload" )
public final class UploadHandler {
...

我映射resteasy服务的RestServices类是:

public final class RestServices extends Application {

  private static final Set<Object> SERVICES = new HashSet<Object>();

  public RestServices() {
    SERVICES.clear();
    SERVICES.add( new UploadHandler() );
  }

  @Override
  public Set<Object> getSingletons() {
    return SERVICES;
  }

  public static Set<Object> getServices() {
    return SERVICES;
  }

}

我的错误在哪里?我应该在web.xml中添加一些内容吗? 我将所有应用程序所需的jar添加到weblogic服务器lib文件夹的lib文件夹中但没有任何更改,我得到了同样的错误。

2 个答案:

答案 0 :(得分:2)

org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher

引起

@WebFilter(asyncSupported = true)

public class Filter30Dispatcher extends FilterDispatcher
{
...
}

我排除了相关的Jar文件async-http-servlet-3.0-3.0.7.Final.jar,这解决了问题。

答案 1 :(得分:2)

我发现这个问题出现了,因为WebLogic包含了它自己的jax-rs实现,Jersey。摆脱这种异常的一种方法是使用Jersey而不是Resteasy,或者在weblogic.xml中禁用jax-rs库,使用prefer web-inf libraries选项来强制WebLogic使用RestEasy。在我看来,迁移到泽西岛将是这种情况下的最佳选择。