title: ApplicationPath being ignored by wildfly
body: <p>I'm currently trying to setup my first Java-EE (JDK8) Application and can't get the overriding of the Context Root to work with the <code>@ApplicationPath</code> annotation.
  The Application server in use is <strong>Wildfly 16.0.0.Final</strong> and I'm trying to use Resteasy as JAX-RS implementation.</p>
  
  <p>Since I'm using gradle to deploy my application as a war this are my dependencies: ( It's a mess and I'm trying to figure out what I really need and what not, advices always welcome )</p>
  
  <pre><code>    dependencies {
      compileOnly 'org.jboss.logging:jboss-logging:3.3.0.Final'
      compileOnly 'org.apache.logging.log4j:log4j-api:2.8.2'
      compileOnly 'org.eclipse.persistence:javax.persistence:2.1.0'
      compileOnly 'javax.inject:javax.inject:1'
      compileOnly 'javax.transaction:javax.transaction-api:1.2'
      compileOnly 'javax.enterprise:cdi-api:2.0'
      compileOnly 'org.hibernate:hibernate-core:5.4.2.Final'
      compileOnly 'org.hibernate:hibernate-envers:5.4.2.Final'
      compileOnly 'com.fasterxml.jackson.core:jackson-core:2.9.8'
      compileOnly 'com.fasterxml.jackson.core:jackson-annotations:2.9.8'
      compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
      compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
      compile group: 'org.jboss.resteasy', name: 'resteasy-jaxrs', version: '3.6.3.Final'
      compile group: 'org.jboss.resteasy', name: 'jaxrs-api', version: '3.0.12.Final'
  }
  </code></pre>
  
  <p>I verified that wildfly is using an adequate version of resteasy and it is also using 3.6.3.</p>
  
  <p>My Application config looks like this:</p>
  
  <pre><code>import javax.ws.rs.ApplicationPath;
  import javax.ws.rs.core.Application;
  import java.util.HashSet;
  import java.util.Set;
  
  @ApplicationPath("rest/*")
  public class ApplicationConfig extends Application {
      // Intentionally empty. Just used to configure the application path for wildfly
  
      @Override
      public Set&lt;Class&lt;?&gt;&gt; getClasses() {
          final Set&lt;Class&lt;?&gt;&gt; s = new HashSet&lt;&gt;();
          s.add(HelloWorldController.class);
          return s;
      }
  
  }
  </code></pre>
  
  <p>Now I am currently able to successfully deploy my application but the context root is still being set to the name of my war file like this:</p>
  
  <pre><code>18:39:47,586 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 85) WFLYUT0021: Registered web context: '/Rest-Test-1.0' for server 'default-server'
  </code></pre>
  
  <p>When accessing the URL with the war name I can see my log entry of my WebFilter, but The filter is also not being able to correctly perform the chain in addressing it to the correct Class with a matching <code>@Path</code> annotation.(Might this also be a Problem with CDI?)</p>
  
  <p>Update 1:
  Changing the @ApplicationPath to "/rest" or "rest" doesn't change the context root registration either. It still takes the war name as context root.</p>
  
  <p>TL;DR:
  Why is my <code>@ApplicationPath</code> annotation being ignored and why is my webfilter not being able to chain the request because of that?</p>
  
  <p><strong>Solution:</strong></p>
  
  <ol>
  <li>Change dependency from resteasy to compileOnly   </li>
  </ol>
  
  <p>This removed the warning <code>WELD-000167: Class org.jboss.resteasy.core.AsynchronousDispatcher is annotated with @RequestScoped but it does not declare an appropriate constructor therefore is not registered as a bean!</code></p>
  
  <ol start="2">
  <li>Change ApplicationPath to correct path ("/rest")</li>
  </ol>
  
  <p>This made my URI register correctly as root and enabled for the WebFilter to perform the correct chain, since it now can distinct from each component in the URI.</p>
  
  <ol start="3">
  <li>Add jboss-web.xml to the WEB-INF</li>
  </ol>
  
  <p>With the jboss-web.xml like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jboss-web version="10.0"
             xmlns="http://www.jboss.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_10_0.xsd"&gt;
  
      &lt;context-root&gt;/api&lt;/context-root&gt;
      &lt;security-domain&gt;other&lt;/security-domain&gt; &lt;!-- Configure to the security domain used for your deployed application --&gt;
      &lt;server-instance&gt;default-server&lt;/server-instance&gt;
      &lt;virtual-host&gt;default-host&lt;/virtual-host&gt;
  
  &lt;/jboss-web&gt;
  </code></pre>
  
  <p>I was able to override the context root to a much more beautiful one.</p>
  
  <p>If your IDE states an error for the server-instance element you can ignore it, it will still work correctly.</p>