title: Build an Executable War/Jar with Maven, Tomcat 7 and Websocket
body: <p>I'm trying to build an executable WAR/JAR using Maven and Tomcat 7.
  The Project contains Websocket and REST API.</p>
  
  <p>In order to do that, I added the following plugin to the pom.xml file:</p>
  
  <pre><code>    &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;tomcat-run&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;exec-war-only&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;path&gt;/TransSafeGWService&lt;/path&gt;
                          &lt;enableNaming&gt;false&lt;/enableNaming&gt;
                          &lt;finalName&gt;standalone.jar&lt;/finalName&gt;
                          &lt;charset&gt;utf-8&lt;/charset&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
  </code></pre>
  
  <p>After that, since REST Service was working but Websocket Service was not, I added other dependencies to the plugin:</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;tomcat-run&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;exec-war-only&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;path&gt;/TransSafeGWService&lt;/path&gt;
                          &lt;enableNaming&gt;false&lt;/enableNaming&gt;
                          &lt;finalName&gt;standalone.jar&lt;/finalName&gt;
                          &lt;charset&gt;utf-8&lt;/charset&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;dependencies&gt;
  
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat7-websocket&lt;/artifactId&gt;
                      &lt;version&gt;7.0.67&lt;/version&gt;
                  &lt;/dependency&gt;
  
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat-util&lt;/artifactId&gt;
                      &lt;version&gt;7.0.67&lt;/version&gt;
                  &lt;/dependency&gt;
  
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat-coyote&lt;/artifactId&gt;
                      &lt;version&gt;7.0.67&lt;/version&gt;
                  &lt;/dependency&gt;
  
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>Using that dependencies, I get this kind of error:</p>
  
  <pre><code>java.lang.NoSuchMethodError: org.apache.catalina.connector.RequestFacade.upgrade(Ljava/lang/Class;)Lorg/apache/coyote/http11/upgrade/servlet31/HttpUpgradeHandler;
      at org.apache.tomcat.websocket.server.UpgradeUtil.doUpgrade(UpgradeUtil.java:238)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:77)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>In this case what could be the problem?</p>
  
  <p>Below the complete pom.xml file:</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/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.ti.white&lt;/groupId&gt;
  &lt;artifactId&gt;TransSafeGWService&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;TransSafeGWService&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
          &lt;version&gt;1.18&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.13&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jettison&lt;/groupId&gt;
          &lt;artifactId&gt;jettison&lt;/artifactId&gt;
          &lt;version&gt;1.3.7&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.websocket&lt;/groupId&gt;
          &lt;artifactId&gt;javax.websocket-api&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;webXml&gt;WebContent\WEB-INF\web.xml&lt;/webXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.3&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;tomcat-run&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;exec-war-only&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;path&gt;/TransSafeGWService&lt;/path&gt;
                          &lt;enableNaming&gt;false&lt;/enableNaming&gt;
                          &lt;finalName&gt;standalone.jar&lt;/finalName&gt;
                          &lt;charset&gt;utf-8&lt;/charset&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;dependencies&gt;
  
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat7-websocket&lt;/artifactId&gt;
                      &lt;version&gt;7.0.67&lt;/version&gt;
                  &lt;/dependency&gt;
  
  
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat-util&lt;/artifactId&gt;
                      &lt;version&gt;7.0.67&lt;/version&gt;
                  &lt;/dependency&gt;
  
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat-coyote&lt;/artifactId&gt;
                      &lt;version&gt;7.0.67&lt;/version&gt;
                  &lt;/dependency&gt;
  
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
  
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>As requested, following there is the web.xml file</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" 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;TransSafeGWService&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Data Acquisition Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
        &lt;param-value&gt;com.ti.transafe.acquisitionService&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Data Acquisition Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/Service/* &lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>