JBoss EAP 6.2中resteasy-jaxrs和async-http-servlet的正确配置和依赖是什么

时间:2018-03-21 21:21:30

标签: jax-rs resteasy jboss-eap-6

我有一个在jboss-eap-6.2.0上运行REST接口的Web应用程序。在我为org.jboss.resteasy.spi.MethodNotAllowedException实现错误处理程序之前,一切都很好。

首先,MethodNotAllowedException无法解析为某种类型。通过使用resteasy-jaxrsHttpServlet30Dispatcher和servlet添加依赖项来修复此问题。

现在,API上的所有网址都会返回404 Could not find resource for relative

以下是来自Web项目POM的一些依赖项

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.jboss.spec.javax.ws.rs</groupId>
    <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
    <scope>provided</scope>
</dependency>
<!-- app was working well (without an implementation of MethodNotAllowedException) before this was added -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>2.3.7.Final-redhat-2</version>
    <scope>provided</scope>
</dependency>

以下是web.xml(在上述更改之前根本不需要)

<?xml version="1.0" encoding="ISO-8859-1" ?>
<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">

    <context-param>
        <param-name>resteasy.servlet.mapping.prefix</param-name>
        <param-value>/rest</param-value>
    </context-param>
    <servlet>
        <servlet-name>Resteasy</servlet-name>
        <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher</servlet-class>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resteasy</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>     

以下是jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> 
    <deployment>
        <dependencies>
            <!-- this module should be loaded automatically via an implicit system dependency in other JBoss modules... but it looks like it isn't -->
            <module name="org.codehaus.jackson.jackson-mapper-asl" export="true"/>
            <module name="org.jboss.resteasy.resteasy-jaxrs" export="true"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

以下是从POST发送到http://127.0.0.1:8080/TestApp/rest/invoice

的回复

JBWEB000065:HTTP状态404 - 无法找到相对的资源:/完整路径的发票:http://127.0.0.1:8080/TestApp/rest/invoice/

JBWEB000309:输入 JBWEB000067:状态报告

JBWEB000068:消息无法找到相对的资源:/完整路径的发票:http://127.0.0.1:8080/TestApp/rest/invoice/

JBWEB000069:description JBWEB000124:请求的资源不可用。

JBoss Web / 7.2.2.Final-redhat-1

0 个答案:

没有答案