title: Wildfly service deployed but resource not found
body: <p>I have just started a webapp project in Wildfly, resteasy using maven. It seems from the logs that the service is correctly deployed, but I don't know what is wrong that I cannot access the resources.</p>
  
  <p>I have tried using the autoscan functionality, defining the @Application, etc. but none of them worked.</p>
  
  <p>The outcome from the server log for the final code I post is:</p>
  
  <pre><code>20:57:25,781 INFO  [stdout] (ServerService Thread Pool -- 66) ************ Constructor **********
  
  20:57:25,781 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 66) RESTEASY002225: Deploying javax.ws.rs.core.Application: class es.domain.prj.rest.JaxRsActivator
  20:57:25,781 INFO  [stdout] (ServerService Thread Pool -- 66) ************ Initializing **********
  
  20:58:03,634 INFO  [stdout] (ServerService Thread Pool -- 66) *** REST SERVICE ****
  
  20:58:09,600 INFO  [stdout] (ServerService Thread Pool -- 66) ************ Initializing **********
  
  20:58:11,113 INFO  [stdout] (ServerService Thread Pool -- 66) *** REST SERVICE****
  
  20:58:13,440 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 66) RESTEASY002220: Adding singleton resource es.domain.prj.rest.RestService from Application class es.domain.prj.rest.JaxRsActivator
  20:58:13,633 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0021: Registered web context: /prj
  </code></pre>
  
  <p>I have tried to access to:</p>
  
  <p><code>http://localhost:8080/prj/jlanza/resource</code> --> Not found</p>
  
  <p><code>http://localhost:8080/prj/jlanza</code>          --> Not found</p>
  
  <p><code>http://localhost:8080/prj/resource</code>        --> Not found</p>
  
  <p>Could you please give me some hints? Where are the resources registered? I know it has to be a quite silly thing, but I'm not able to identify it.</p>
  
  <p>Find below the source code, pom.xml and web.xml files.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong><em>web.xml</em></strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    id="WebApp_ID" 
    version="3.0"&gt;
  
    &lt;display-name&gt;MyFirstProject&lt;/display-name&gt;
  
    &lt;!-- Auto scan REST service --&gt;
    &lt;context-param&gt;
      &lt;param-name&gt;resteasy.scan&lt;/param-name&gt;
      &lt;param-value&gt;false&lt;/param-value&gt;
    &lt;/context-param&gt;
  
    &lt;context-param&gt;
      &lt;param-name&gt;javax.ws.rs.Application&lt;/param-name&gt;
      &lt;param-value&gt;es.domain.prj.rest.JaxRsActivator&lt;/param-value&gt;
    &lt;/context-param&gt;
  
    &lt;!-- this needs to be the same as servlet-mapping url-pattern --&gt;
    &lt;!-- set this if you map the Resteasy servlet to something other than /* --&gt;
    &lt;!-- 
    &lt;context-param&gt;
        &lt;param-name&gt;resteasy.servlet.mapping.prefix&lt;/param-name&gt;
        &lt;param-value&gt;/resteasy&lt;/param-value&gt;
     &lt;/context-param&gt;
     --&gt;
  
    &lt;listener&gt;
      &lt;listener-class&gt;
        org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
      &lt;/listener-class&gt;
    &lt;/listener&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;resteasy-servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
        org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
      &lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong><em>pom.xml</em></strong></p>
  
  <pre><code>&lt;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"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;es.domain&lt;/groupId&gt;
    &lt;artifactId&gt;prj&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;Maven Webapp&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;slf4j.version&gt;1.7.21&lt;/slf4j.version&gt;
      &lt;!-- current log4j 2 release --&gt;
      &lt;log4j.version&gt;2.5&lt;/log4j.version&gt; 
      &lt;jena.version&gt;3.0.1&lt;/jena.version&gt;
      &lt;jboss.resteasy.version&gt;3.0.16.Final&lt;/jboss.resteasy.version&gt;
      &lt;javax.cdi-api.version&gt;1.2&lt;/javax.cdi-api.version&gt;
      &lt;javax.servlet.version&gt;3.0-alpha-1&lt;/javax.servlet.version&gt;
  
      &lt;maven.plugin.version&gt;3.5.1&lt;/maven.plugin.version&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Binding for Log4J --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-slf4j-impl&lt;/artifactId&gt;
          &lt;version&gt;${log4j.version}&lt;/version&gt;
          &lt;exclusions&gt;
            &lt;exclusion&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;!-- Log4j API and Core implementation required for binding --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
        &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
        &lt;version&gt;${log4j.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
        &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;
        &lt;version&gt;${log4j.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Import the JAX-RS API, we use provided scope as the API is included 
          in JBoss WildFly --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
        &lt;artifactId&gt;resteasy-jaxrs&lt;/artifactId&gt;
        &lt;version&gt;${jboss.resteasy.version}&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;javax.enterprise&lt;/groupId&gt;
        &lt;artifactId&gt;cdi-api&lt;/artifactId&gt;
        &lt;version&gt;${javax.cdi-api.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;!-- 
      &lt;dependency&gt;
        &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
        &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
        &lt;version&gt;${javax.servlet.version}&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  --&gt;     
      &lt;!-- Jena library --&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.apache.jena&lt;/groupId&gt;
         &lt;artifactId&gt;apache-jena-libs&lt;/artifactId&gt;
         &lt;type&gt;pom&lt;/type&gt;
         &lt;version&gt;${jena.version}&lt;/version&gt;
         &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;artifactId&gt;log4j&lt;/artifactId&gt;
            &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;/exclusion&gt;
         &lt;/exclusions&gt;
      &lt;/dependency&gt; 
    &lt;/dependencies&gt;
  
    &lt;build&gt;
      &lt;finalName&gt;prj&lt;/finalName&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;${maven.plugin.version}&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.8&lt;/source&gt;
            &lt;target&gt;1.8&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
       &lt;/plugins&gt;
     &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong><em>JaxRsActivator.java</em></strong></p>
  
  <pre><code>package es.domain.prj.rest;
  
  import java.util.HashSet;
  import java.util.Set;
  
  //import javax.ws.rs.ApplicationPath;
  import javax.ws.rs.core.Application;
  
  //@ApplicationPath("/api")
  public class JaxRsActivator extends Application {
  
      public JaxRsActivator() {
        System.out.println("************ Constructor **********");
      }
  
      @Override
      public Set&lt;Class&lt;?&gt;&gt; getClasses() {
          Set&lt;Class&lt;?&gt;&gt; classes = new HashSet&lt;Class&lt;?&gt;&gt;();
  //        classes.add(MyResource.class);
          return classes;
      }
  
      @Override
      public Set&lt;Object&gt; getSingletons() {
    System.out.println("************ Initializing **********");
          Set&lt;Object&gt; singletons = new HashSet&lt;Object&gt;();
          singletons.add(new RestService());
          return singletons;
      }
  }
  </code></pre>
  
  <p><strong><em>RestService.java</em></strong></p>
  
  <pre><code>package es.domain.prj.rest;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  import javax.ws.rs.core.Response.Status;
  
  @Path("/jlanza")
  public class RestService {
  
      public RestService() {
        System.out.println("*** REST SERVICE ****");
      }
  
      @GET
      @Path("resource")
      @Produces(MediaType.TEXT_PLAIN)
      public Response getResource() {
        System.out.println("***Calling function****");
        return Response.status(Status.OK).entity("working").build();
      }
  }
  </code></pre>