samedi 13 juin 2015

Jboss Resteasy Service not working (404)

For some reason my REST-Service wont be registered correctly under Jboss Wildfy8. I generated a default JavaEE Project under IntelliJ Idea.

@Path("parser")
public class RestResource

 {


@GET
@Path("test")
@Produces(MediaType.TEXT_PLAIN)
public String test() {
    return "I am Test";
}

WebXml:

<web-app xmlns="http://ift.tt/19L2NlC"
         xmlns:xsi="http://ift.tt/ra1lAU"
         xsi:schemaLocation="http://ift.tt/19L2NlC http://ift.tt/1drxgYl"
         version="3.1">
    <listener>
        <listener-class>
            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
        </listener-class>
    </listener>

    <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>
    <context-param>
        <param-name>resteasy.scan</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>resteasy.servlet.mapping.prefix</param-name>
        <param-value>/</param-value>
    </context-param>
</web-app>

dependency of the resteasy lib in the pom.xml:

org.jboss.resteasy resteasy-jaxrs 3.0.11.Final

I tried to fix this by adding this class to my Project

@ApplicationPath("/rest")
public class JaxRsActivator extends Application {
}

Then I edited the web.xml by adding this init-parameter, that should not be needed under wildfly:

   <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>rest.RestResource</param-value>
    </init-param>

Anyway I still cannot access http://localhost:8080/my-appliation/parser/test. The Server is online, I can access the Wildfly-Testpage. when I just enter the registered webcontext of my application (http://localhost:8080/my-appliation) I receive an FORBIDDEN message.

This makes me wonder if I have forgotten something in my server configuration (I did no config so far) or in my project setup.

Aucun commentaire:

Enregistrer un commentaire