简体   繁体   English

JBOSS 7.1.0错误 - 无法找到类org.jboss.resteasy.core.AsynchronousDispatcher的公共构造函数

[英]JBOSS 7.1.0 error - Unable to find a public constructor for class org.jboss.resteasy.core.AsynchronousDispatcher

I am trying to migrate my spring MVC based REST application to Jboss 7.1.0. 我正在尝试将基于Spring MVC的REST应用程序迁移到Jboss 7.1.0。 At startup, the Jboss initialisation shows that everything was started up correctly with all war files deployed successfully. 在启动时,Jboss初始化显示一切都已正确启动,所有war文件都已成功部署。

I had quite a few problems getting the integration between Spring MVN and Jboss's RestEasy service and im wondering if this is another conflict between jboss resteasy with Spring MVN. 我在Spring MVN和Jboss的RestEasy服务之间进行集成时遇到了很多问题,我想知道这是否是jboss resteasy与Spring MVN之间的另一个冲突。

When i make a request to the REST service i get the following error: 当我向REST服务发出请求时,我收到以下错误:

12:52:31,541 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Root WebApplicationContext: initialization completed in 3035 ms
12:52:31,845 INFO  [org.jboss.web] (MSC service thread 1-5) JBAS018210: Registering web context: /MyRestService
12:52:31,875 INFO  [org.jboss.as] (MSC service thread 1-5) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 53526ms - Started 390 of 468 services (72 services are passive or on-demand)
12:52:32,034 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "MyRestService.war"
12:54:10,117 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyRestService]] (http--127.0.0.1-8080-1) StandardWrapper.Throwable: java.lang.RuntimeException: Unable to find a public constructor for class org.jboss.resteasy.core.AsynchronousDispatcher
        at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.registered(POJOResourceFactory.java:35) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:121) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:107) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:84) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:73) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:367) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]

12:54:10,194 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyRestService].[javax.ws.rs.core.Application]] (http--127.0.0.1-8080-1) Allocate exception for servlet javax.ws.rs.core.Application: java.lang.RuntimeException: Unable to find a public constructor for class org.jboss.resteasy.core.AsynchronousDispatcher
        at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.registered(POJOResourceFactory.java:35) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:121) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:107) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:84) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:73) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:367) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]

The error does not make any sense and the only thing i recognise from it is the RESTEasy service servlet name. 这个错误没有任何意义,我唯一能认识到的是RESTEasy服务servlet名称。 This is configured as follows - which works fine in Jboss 7.0.2 这配置如下 - 在Jboss 7.0.2中工作正常

<servlet-mapping>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <url-pattern>/rest/*</url-pattern>
</servlet-mapping>  

I have also seen this exception when using RESTEasy on JBoss 7.1.1 (without Spring). 在JBoss 7.1.1(没有Spring)上使用RESTEasy时,我也看到了这个异常。 It was wrapped like this: 它包裹得像这样:

Allocate exception for servlet [project class reference]: java.lang.RuntimeException: Unable to find a public constructor for class org.jboss.resteasy.core.AsynchronousDispatcher

The solution was to exclude all RESTEasy jars from the war. 解决方案是从战争中排除所有RESTEasy罐子。 In Maven, you can do this by ensuring any required RESTEasy dependencies are declared with Maven's 'provided' scope, as these are provided by JBoss, and excluding any transitive RESTEasy dependencies (see this link for an example). 在Maven中,您可以通过确保使用Maven的“提供”范围声明任何所需的RESTEasy依赖关系来实现此目的,因为这些是由JBoss提供的,并且不包括任何传递的RESTEasy依赖关系(请参阅此链接以获取示例)。 You can check if you have any RESTEasy dependencies by changing to the directory containing your pom.xml and issuing a command such as: 您可以通过更改到包含pom.xml的目录并发出如下命令来检查是否有任何RESTEasy依赖项:

mvn dependency:tree | grep "resteasy"

If you are using your web.xml for JAX-RS activation, you may also need to switch to the class-based approach demonstrated in the RESTEasy docs . 如果您使用web.xml进行JAX-RS激活,则可能还需要切换到RESTEasy文档中演示的基于类的方法。 These solutions to this issue are mentioned by a RESTEasy developer here and here . RESTEasy开发人员在这里这里提到了这个问题的解决方案。

我远不是REST专家,但javax.ws.rs.core.Application不是servlet。

问题不在于RESTful服务的声明方式,这种方式对于JAX-RS 1.1来说是非常标准的(与Servlet James没有关系!!),但它是JBoss中的一个错误,你需要在Application子类中指定RESTful资源,否则它会尝试将AsyncDisp ***挂载为RESTful服务。

I solved this problems by doing the following steps: 我通过执行以下步骤解决了这个问题:

Step 1. Create your service registration class 步骤1.创建服务注册类

public class RESTApplication extends javax.ws.rs.core.Application {

private Set<Object> singletons = new HashSet<Object>();

public RESTApplication () {
    singletons.add(new RestService());
}

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

} }

Step 2: Edit your web.xml 第2步:编辑您的web.xml

<!-- Resteasy -->
<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/rest</param-value>
</context-param>

<servlet>
    <servlet-name>resteasy-servlet</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>yourpackage.RESTApplication</param-value>
    </init-param>
</servlet>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.jboss.resteasy.client.ClientResponseFailure:无法找到内容类型为文本/纯文本且类型为类java.lang.String的MessageBodyReader - org.jboss.resteasy.client.ClientResponseFailure: Unable to find a MessageBodyReader of content-type text/plain and type class java.lang.String JBoss + RestEasy + Jackson:无法将org.jboss.resteasy.core.ServerResponse强制转换为org.jboss.resteasy.specimpl.BuiltResponse - JBoss + RestEasy + Jackson : org.jboss.resteasy.core.ServerResponse cannot be cast to org.jboss.resteasy.specimpl.BuiltResponse org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无法找到类型的响应对象的MessageBodyWriter:媒体类型:application / xml - org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: of media type: application/xml org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无法为类型的响应对象找到MessageBodyWriter - org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type ClassNotFoundException:org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter - ClassNotFoundException: org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter 错误 [org.jboss.resteasy.resteasy_jaxrs.i18n](默认任务 2)RESTEASY002010 - ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-2) RESTEASY002010 JAX-RS:“RESTEASY002005:执行 GET org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure 失败 - JAX-RS: "RESTEASY002005: Failed executing GET org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure 在 JBoss 7.1.0 上部署 Primefaces 应用程序时出错 - Error deploying Primefaces application on JBoss 7.1.0 如何用 Spring 或 POJO 类替换 org.jboss.resteasy.core.ResourceMethodInvoker - How to replace org.jboss.resteasy.core.ResourceMethodInvoker with Spring or POJO classes 无法在Jboss 7中添加resteasy本地模块 - Unable to add resteasy local module in Jboss 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM