title: How to get Spring to use WildFly, rather than Tomcat?
body: <p>I am trying to implement JSR annotations to handle caching. After a lot of research and several questions on SO I got to the point below. When I try to run this however it says </p>
  
  <pre><code>java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer"}}
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>HelloService.java</p>
  
  <pre><code>@Path("/helloservice")
  @EnableCaching
  public class HelloService extends CachingSetup{
  
      @GET
      @Path("/unsecured")
      @Produces({"text/plain"})
      @CacheResult
      public String testUnsecured(){
          return "Unsecured user";
      }
  }
  </code></pre>
  
  <p>CachingSetup.java</p>
  
  <pre><code>import static java.util.concurrent.TimeUnit.SECONDS;
  import javax.cache.CacheManager;
  import javax.cache.configuration.MutableConfiguration;
  import javax.cache.expiry.Duration;
  import javax.cache.expiry.TouchedExpiryPolicy;
  import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
  import org.springframework.stereotype.Component;
  
    @Component
    public class CachingSetup implements JCacheManagerCustomizer
    {
      @Override
      public void customize(CacheManager cacheManager)
      {
        cacheManager.createCache("basicCache", new MutableConfiguration&lt;&gt;()  
          .setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(new Duration(SECONDS, 10))) 
          .setStoreByValue(false)
          .setStatisticsEnabled(true));
      }
    }
  </code></pre>
  
  <p>ehcache.xml</p>
  
  <pre><code>&lt;config
      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
      xmlns='http://www.ehcache.org/v3'  
      xmlns:jsr107='http://www.ehcache.org/v3/jsr107'&gt;  
  
    &lt;service&gt;
      &lt;jsr107:defaults&gt;
        &lt;jsr107:cache name="basicCache" template="heap-cache"/&gt; 
      &lt;/jsr107:defaults&gt;
    &lt;/service&gt;
  
    &lt;cache-template name="heap-cache"&gt;
      &lt;listeners&gt;    
        &lt;listener&gt;
          &lt;class&gt;org.terracotta.ehcache.EventLogger&lt;/class&gt;
          &lt;event-firing-mode&gt;ASYNCHRONOUS&lt;/event-firing-mode&gt;
          &lt;event-ordering-mode&gt;UNORDERED&lt;/event-ordering-mode&gt;
          &lt;events-to-fire-on&gt;CREATED&lt;/events-to-fire-on&gt; 
          &lt;events-to-fire-on&gt;UPDATED&lt;/events-to-fire-on&gt; 
          &lt;events-to-fire-on&gt;EXPIRED&lt;/events-to-fire-on&gt; 
          &lt;events-to-fire-on&gt;REMOVED&lt;/events-to-fire-on&gt; 
          &lt;events-to-fire-on&gt;EVICTED&lt;/events-to-fire-on&gt; 
        &lt;/listener&gt;
      &lt;/listeners&gt;
      &lt;resources&gt;
        &lt;heap unit="entries"&gt;2000&lt;/heap&gt; 
        &lt;offheap unit="MB"&gt;100&lt;/offheap&gt; 
      &lt;/resources&gt;
    &lt;/cache-template&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.sentiment360&lt;/groupId&gt;
      &lt;artifactId&gt;QuteeDemoRest&lt;/artifactId&gt;
      &lt;version&gt;v1&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;QuteeDemoRest&lt;/name&gt;
  
      &lt;properties&gt;
          &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
          &lt;parent&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; 
        &lt;version&gt;1.3.2.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax&lt;/groupId&gt;
              &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
              &lt;version&gt;7.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.mariadb.jdbc&lt;/groupId&gt;
              &lt;artifactId&gt;mariadb-java-client&lt;/artifactId&gt;
              &lt;version&gt;1.5.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-multipart-provider&lt;/artifactId&gt;
              &lt;version&gt;3.0.14.Final&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-links --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-links&lt;/artifactId&gt;
              &lt;version&gt;3.1.4.Final&lt;/version&gt;
          &lt;/dependency&gt; 
          &lt;!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-jaxrs&lt;/artifactId&gt;
              &lt;version&gt;3.1.4.Final&lt;/version&gt;
          &lt;/dependency&gt;
  &lt;!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxb-provider --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
              &lt;artifactId&gt;resteasy-jaxb-provider&lt;/artifactId&gt;
              &lt;version&gt;1.0-RC1&lt;/version&gt;
          &lt;/dependency&gt;        
          &lt;!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
              &lt;artifactId&gt;jjwt&lt;/artifactId&gt;
              &lt;version&gt;0.6.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.ehcache/ehcache --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.ehcache&lt;/groupId&gt;
              &lt;artifactId&gt;ehcache&lt;/artifactId&gt;
              &lt;version&gt;3.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
            &lt;groupId&gt;javax.cache&lt;/groupId&gt;
            &lt;artifactId&gt;cache-api&lt;/artifactId&gt;
          &lt;/dependency&gt;
                        &lt;!--SPRING--&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-cache&lt;/artifactId&gt; 
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; 
      &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&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;3.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                      &lt;compilerArguments&gt;
                          &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                      &lt;/compilerArguments&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.6&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;copy&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
                              &lt;silent&gt;true&lt;/silent&gt;
                              &lt;artifactItems&gt;
                                  &lt;artifactItem&gt;
                                      &lt;groupId&gt;javax&lt;/groupId&gt;
                                      &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
                                      &lt;version&gt;7.0&lt;/version&gt;
                                      &lt;type&gt;jar&lt;/type&gt;
                                  &lt;/artifactItem&gt;
                              &lt;/artifactItems&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>