Getting 404 trying to render a JSP from Jersey 2
<p>I'm trying to make a simple example of a web application using Jersey 2 and JSP, and to deploy it on Glassfish 4. However, I keep getting 404 errors trying to access my only resource. </p>

<p>First, the project structure:</p>

<p><a href="https://i.stack.imgur.com/nvkYK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nvkYK.png" alt="Project structure"></a></p>

<p>Here are the important classes and files:</p>

<p><code>web.xml</code> I'm setting Jersey as a filter, instead of a servlet, because I read it needs to be defined that way in order to make it work with JSP.</p>

<pre><code>&lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;

  &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;

  &lt;filter&gt;
    &lt;filter-name&gt;jersey&lt;/filter-name&gt;
    &lt;filter-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/filter-class&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
      &lt;param-value&gt;com.xxx.sample-jersey2&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;jersey.config.servlet.filter.forwardOn404&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
    &lt;/init-param&gt;
  &lt;/filter&gt;

  &lt;filter-mapping&gt;
    &lt;filter-name&gt;jersey&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;

  &lt;!--&lt;welcome-file-list&gt;--&gt;
    &lt;!--&lt;welcome-file&gt;index.html&lt;/welcome-file&gt;--&gt;
    &lt;!--&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;--&gt;
    &lt;!--&lt;welcome-file&gt;movies.jsp&lt;/welcome-file&gt;--&gt;
  &lt;!--&lt;/welcome-file-list&gt;--&gt;

&lt;/web-app&gt;
</code></pre>

<p><code>movies.jsp</code> is extremely simple:</p>

<pre><code>&lt;html&gt;
&lt;body&gt;
  &lt;h2&gt;Listing Movies&lt;/h2&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The custom ResourceConfig (which I'm not even sure I need)</p>

<pre><code>package com.xxx.jersey2.config;

import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.mvc.jsp.JspMvcFeature;

public class CustomResourceConfig extends ResourceConfig {
    public CustomResourceConfig() {
        packages("com.xxx");
        register(LoggingFilter.class);
        register(JspMvcFeature.class);
        // it may be also jersey.config.server.mvc.templateBasePath
        property("jersey.config.server.mvc.templateBasePath", "/WEB-INF/jsp");
        // ... more properties as needed ...
    }
}
</code></pre>

<p>And my controller for the Movies:</p>

<pre><code>package com.xxx.jersey2.web;

import com.xxx.jersey2.model.Movie;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.glassfish.jersey.server.mvc.Viewable;

@Path("movies")
public class MoviesController {
    @GET
    @Path("/list")
    public Viewable getMovies() {
        List&lt;Movie&gt; movies = new ArrayList&lt;Movie&gt;();

        movies.add(new Movie("Million Dollar Baby", "Hillary Swank"));
        movies.add(new Movie("Toy Story", "Buzz Light Year"));
        movies.add(new Movie("Hunger Games", "Jennifer Lawrence"));

        return new Viewable("movies.jsp");
    }
}
</code></pre>

<p>If I try to access <code>https://localhost:8181/sample-jersey2/</code> the simple <code>index.jsp</code> is rendered (which only shows a Hello World message). However, trying to access <code>https://localhost:8181/sample-jersey2/movies/list/</code> gives me a 404 error.</p>

<p>Any ideas on this would be greatly appreciated.
Best regards</p>