title: Spring Boot with Struts Filter and Tomcat
body: <p>I am migrating a Struts2 application to Spring Boot. I defined the <code>StrutsPrepareAndExecuteFilter</code> inside my Application boot class.</p>
  <pre><code>@SpringBootApplication
  public class ClearApplication extends SpringBootServletInitializer {
  
    public static void main(String[] args) {
      SpringApplication.run(ClearApplication.class, args);
    }
  
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
      return application.sources(ClearApplication.class);
    }
  
    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
      Collection&lt;String&gt; urlPatterns = new ArrayList&lt;&gt;();
      urlPatterns.add(&quot;/*&quot;);
      FilterRegistrationBean registrationBean = new FilterRegistrationBean();
      StrutsPrepareAndExecuteFilter struts = new StrutsPrepareAndExecuteFilter();
      registrationBean.setFilter(struts);
      registrationBean.setName(&quot;strutsFilter&quot;);
      registrationBean.setOrder(1);
      registrationBean.setUrlPatterns(urlPatterns);
      return registrationBean;
    }
  }
  </code></pre>
  <p>The <code>pom.xml</code> file configuration is below</p>
  <pre><code>&lt;groupId&gt;com.study.pack&lt;/groupId&gt;
  &lt;artifactId&gt;clear&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;name&gt;clear&lt;/name&gt;
  &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  </code></pre>
  <p>My action class has one simple Struts action and another json action</p>
  <pre><code>@Action(value = &quot;welcome&quot;, results = { @Result(name = &quot;success&quot;, location = &quot;result.jsp&quot;) })
  public String execute() {
      return &quot;success&quot;;
  }
  
  @Action(value = &quot;users&quot;, results = { @Result(name = &quot;success&quot;, type = &quot;json&quot;, params = { &quot;root&quot;, &quot;userList&quot; }) })
  public String users() {
      userList = new ArrayList&lt;&gt;();
      userList.add(new User(&quot;Carl&quot;, &quot;15&quot;, &quot;M&quot;));
      userList.add(new User(&quot;Rick&quot;, &quot;30&quot;, &quot;M&quot;));
      userList.add(new User(&quot;Michonne&quot;, &quot;26&quot;, &quot;F&quot;));
      return &quot;success&quot;;
  }
  </code></pre>
  <p>When, I am deploying the application on my local Tomcat server. I am able to access the action URLs</p>
  <p><code>http://localhost:8080/clear/welcome</code></p>
  <p><code>http://localhost:8080/clear/users</code></p>
  <p>But, when I run the application in STS (or by using maven command), I am getting the standard struts error when accessing the same above URLs</p>
  <blockquote>
  <p><strong>There is no Action mapped for namespace [/clear] and action name [users] associated with context path [].</strong></p>
  </blockquote>
  <p>The <code>application.properties</code> has the following properties</p>
  <pre><code>server.contextPath=/clear
  server.port=8080 
  </code></pre>
  <p>Am I missing any other configuration to get it working ?</p>
  <p><strong>Update:</strong></p>
  <p>As @Roman-C suggested, I checked the startup logs of tomcat server and the context path is identical.</p>
  <p><strong>External Tomcat Server:</strong></p>
  <pre><code>[ost-startStop-1] o.a.c.c.C.[.[localhost].[/clear]         : Initializing Spring embedded WebApplicationContext
  </code></pre>
  <p><strong>Embedded Tomcat Server:</strong></p>
  <pre><code>[ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/clear]  : Initializing Spring embedded WebApplicationContext
  </code></pre>
  <p>The application.properties lies within the folder</p>
  <pre><code>src/main/resources     
  </code></pre>
  <p>Still No luck. Somehow the struts annotations are ignored I guess.</p>
  <p>I have committed the source code in <a href="https://github.com/creativekarma/clear" rel="nofollow noreferrer">GitHub</a>.</p>