title: deploy spring boot websocket sample application to tomcat7
body: <p>Following tutorial helped me to get a spring boot application up and running real fast: <a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="nofollow">https://spring.io/guides/gs/messaging-stomp-websocket/</a></p>
  
  <p>But now I'm stuck trying to generate a war file and deploying it on my tomcat7 application server.</p>
  
  <p>I followed the [instructions][1] to create a deployable war file, but this just isn't working. I don't see any errors in the logs, but I don't see my nice sample application either when I browse to <a href="http://localhost:8080" rel="nofollow">http://localhost:8080</a>.</p>
  
  <p>Here are the steps I took to generate a war file:</p>
  
  <p>1) Modify pom.xml by changing the packaging to war and marking the spring-boot-starter-websocket as provided</p>
  
  <pre><code>&lt;packaging&gt;war&lt;/packaging&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-websocket&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;            
      &lt;/dependency&gt;            
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-messaging&lt;/artifactId&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>2) Modify Application.java to override the SpringBootServletInitializer configure method.</p>
  
  <pre><code>@SpringBootApplication
  public class Application extends SpringBootServletInitializer {
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(Application.class);
      }
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>3) Then I run </p>
  
  <blockquote>
    <p>mvn clean package</p>
  </blockquote>
  
  <p>and deploy the generated war-file, but I just keep getting the default Tomcat welcome page, when I browse to <a href="http://localhost:8080/" rel="nofollow">http://localhost:8080/</a>.</p>
  
  <p>I also tried changing the application contextPath by adding the following application.properties:</p>
  
  <pre><code>server.contextPath=/websocketclient
  server.port=8082
  </code></pre>
  
  <p>But this doesn't solve the problem.</p>