I've recently upgraded a large Java AppEngine project from Java 7 to Java 8. After doing that, org.eclipse.jetty.servlet.ServletHandler.updateMappings started throwing this exception:
java.lang.IllegalStateException: No such servlet: jsp
After some investigation, it appears that removing this block of code from web.xml resolves that problem:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
Once I remove that, though, the pages aren't UTF-8 encoded, so non-ascii characters aren't showing up correctly.
I've tried adding variations of the following to the JSP:
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
I've also gone into the controller and tried to set a character encoding there. The endpoint for serving up the JSP file looks like this:
@GET
@Path("{subResources: .+}")
public Viewable foo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
...
return new Viewable("/index.jsp", map);
}
I also tried creating a filter and setting the encoding through that, but that didn't have any effect, either. When I use the network inspector in my browser, the Content-Type header does come back as text/html;charset=utf-8... just the text is wrong, like it was assumed to be ascii somewhere along the chain.
The project uses Guice and Jersey. Unfortunately it is a very large and complex project and I'm unable to provide the full source, or a smaller project that reproduces the issue. Another part of the web.xml file sets up Guice like this:
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.myproject.GuiceConfig</listener-class>
</listener>
There is then a Guice JerseyServletModule that sets things up further, including a block like this:
jerseyParams.put("com.sun.jersey.config.property.packages", StringUtils.join(packages, ";"));
jerseyParams.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
jerseyParams.put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, "(/(tportal|images|styles|jsp)/.*|.*html|.*jsp|" +
".*ico|.*png|.*jpg|.*css|.*js|.*txt|.*xml)");
filterRegex("^((?!^\\/(admin|_ah)((\\/\\w+)|\\/?$)).)*$").through(GuiceContainer.class, jerseyParams);
The last thing to add is that some of the libraries the project uses are quite out of date. I'd ideally not update any which introduce breaking changes in later versions, if any do that. For example, version 1.11 of Jersey guice and jersey server are used. I haven't tried upgrading to 1.19.4 to know if there are breaking changes or if it would help at all.
Here are some related posts I've referenced in my attempts to resolve this: