简体   繁体   English

Resteasy路径JBoss

[英]Resteasy paths JBoss

I am having trouble navigating to my restful service using resteasy 2.1 on localhost and was hoping someone here might be able to help me. 我在localhost上使用resteasy 2.1导航到我的Restful服务时遇到了麻烦,希望这里的某人能够为我提供帮助。

I have built an EAR file with a WAR inside and is seems to compile and deploy to JBoss5 ok. 我已经建立了一个带有WAR的EAR文件,并且似乎可以编译并部署到JBoss5了。

My service simplified: 我的服务简化了:

@Path("RequestReply")
public class Replier {

    @GET
    @Path("request")
    public String getReply(@QueryParam("id") @DefaultValue("") String id){
            if (id.length > 0){
                return "ACK";
            }
            return "NACK";
        }
}

My web.xml file is standard: 我的web.xml文件是标准文件:

<?xml version="1.0" encoding="UTF-8"?>

<web-app>
    <display-name>Test service</display-name>

    <listener>
        <listener-class>
            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
        </listener-class>
    </listener>

    <context-param>
        <param-name>resteasy.scan</param-name>
        <param-value>true</param-value>
    </context-param>

    <servlet>
        <servlet-name>Resteasy</servlet-name>

        <servlet-class>
            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Resteasy</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

</web-app>

So I try to access my API using 所以我尝试使用

http://localhost:8080/RequestReply/request?id=1234 http:// localhost:8080 / RequestReply / request?id = 1234

But I get 404 errors. 但是我收到404错误。

Can anyone tell me what I am doing wrong? 谁能告诉我我在做什么错?

Application.xml: Application.xml:

<?xml version="1.0" encoding="UTF-8"?> 
    <application xmlns="java.sun.com/xml/ns/javaee"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/application_5.xsd"; version="5"> 

        <display-name>Reseasy</display-name> 

        <module> 
            <java>simple.jar</java> 
        </module> 

    </application>

Ok so I would suggest trying something like: 好的,所以我建议尝试类似的方法:

<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_5.xsd"
             version="5">

    <display-name>Reseasy</display-name>

    <module>
        <web>
            <web-uri>Replier.war</web-uri>
            <context-root>/api</context-root>
        </web>
    </module>

</application>

Here the Replier.war refers to the name of the WAR file you create and /api refers to the base of your request URL. 在这里,Replier.war指代您创建的WAR文件的名称,/ api指代请求URL的基础。 So it should look like: 所以它应该看起来像:

http://localhost:8080/api/RequestReply/request?id=1234 http:// localhost:8080 / api / RequestReply / request?id = 1234

Give that a shot! 试一试!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM