1
votes

I've been trying hard during an entire week to make it work but there no way I could make wildfly work even with a simple rest hello world app... Went through all Resteasy doc, wildfly resteasy examples, several tutorial, maven doc linked to wildfly and resteasy and still...

I use JDK 1.8, wildfly 10.x, and resteasy 3.0.19 (which is my wildfly default version).

It seems like wildfly just don't want to see the content of the war. I mean web.xml is ok but my classes are totaly transparent. I get classnotfound on my application class when trying to define resteasy servlet localy and just nothing when using wildfly builtin servlet.

Here are my last pom.xml, web.xml and one and only java class (I tried already with javax.ws.rs.Application class and annotation it's same result. I tried also with custom servlet mapping and all...).

Pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.me.test</groupId>
  <artifactId>testrest</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>testrest Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>sun.jdk</groupId>
      <artifactId>jconsole</artifactId>
      <version>jdk</version>
      <scope>system</scope>
      <systemPath>C:/Program Files/Java/jdk1.8.0_112/lib/jconsole.jar</systemPath>
    </dependency>  
    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
      <version>3.0.19.Final</version>
      <scope>provided</scope>
    </dependency>  
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>testrest</finalName>
  </build>
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
</project>

Web.xml

<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>Archetype Created Web Application</display-name>
  <!--  this tells RESTEasy to load resource classes -->
    <context-param>
        <param-name>resteasy.scan</param-name>
        <param-value>true</param-value>
    </context-param>

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

and my only class :

package com.me.services;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/hello")
public class HelloService {
    @GET
    @Produces("text/plain")
    public String sayHello() {
        return "Hello World";
    }
}

And when I try to access my service once deployed I got : http://localhost:8080/testrest/ : Hello world! (From my index.html file) http://localhost:8080/testrest/rest : Not Found localhost:8080/testrest/rest/hello : Not Found

When I check my deployment in wildfly i can see my application but no servlet in undertow...

As explained before I tried many things like when trying to declare my own servlet in web.xml it works but then it can't find the application class in the war though it's actually there... Really seems like Wildfly doesn't see anything appart from my web.xml :/

1
What happens if you change the /rest/* to /* ?Will T

1 Answers

1
votes

use http://localhost:8080/testrest/rest/hello/ and also add path to your sayHello method