title: How do you get embedded Jetty 9 to successfully resolve the JSTL URI?
body: <p>I'm packaging a Web Application Archive (.war) so that it can be started via <code>java -jar webapp.war</code> in a shell by launching an embedded copy of Jetty 9 using this code in a main class:</p>
  
  <pre><code>int port = Integer.parseInt(System.getProperty("port", "80")); // I know this has implications :)
  String contextPath = System.getProperty("contextPath", "");
  Server server = new Server(port);
  ProtectionDomain domain = Deployer.class.getProtectionDomain();
  URL location = domain.getCodeSource().getLocation();
  WebAppContext webapp = new WebAppContext();
  webapp.setContextPath("/" + contextPath);
  webapp.setWar(location.toExternalForm());
  server.setHandler(webapp);
  server.start();
  server.join();
  </code></pre>
  
  <p>However, I'm running into this error when the first JSP containing a JSTL taglib declaration gets compiled:</p>
  
  <pre><code>org.apache.jasper.JasperException: /WEB-INF/html/user/login.jsp(2,62) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
  at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
  at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
  at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:172)
  at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:431)
  at org.apache.jasper.compiler.TagLibraryInfoImpl.&lt;init&gt;(TagLibraryInfoImpl.java:240)
  at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:502)
  at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:582)
  at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1652)
  at org.apache.jasper.compiler.Parser.parse(Parser.java:185)
  at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
  at org.apache.jasper.compiler.ParserController.parse(ParserController.java:145)
  at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:212)
  at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
  at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
  etc...
  </code></pre>
  
  <p>The first couple lines of that JSP are as follows:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" isELIgnored="false" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  </code></pre>
  
  <p>I've looked around quite a bit (this doesn't seem to be a new issue) and have tried the following solutions:</p>
  
  <ul>
  <li>Slimming down my dependencies and looking for conflicts (currently I'm only depending on <code>jetty-server</code>, <code>jetty-webapp</code>, and <code>jetty-jsp</code>, all version <code>9.0.4.v20130625</code>)</li>
  <li>Specifying an explicit <code>&lt;taglib&gt;</code> mapping in the webapp's web.xml file that points to JSTL directly (got this idea from reading the JSP spec)</li>
  <li>Modifying the server classpath as per <a href="https://stackoverflow.com/a/12850147/1771454">this answer</a></li>
  <li>Taking advantage of methods of WebAppContext such as <code>addServerClass</code> and <code>setParentLoaderPriority</code></li>
  </ul>
  
  <p>According to <a href="http://www.eclipse.org/jetty/documentation/current/configuring-jsp.html#using-jstl-taglibs-for-jetty7-jetty8" rel="nofollow noreferrer">Jetty's documentation</a>, using JSTL should just work, but I think the embedded context may be changing the way JSTL gets loaded and causing it to fail.</p>
  
  <p>Would appreciate any ideas or suggestions. This setup would be replacing an older setup that did the same thing successfully on Windows but was not functioning on Linux due to the inclusion of an old dependency that brought in <a href="http://jira.codehaus.org/browse/JETTY-1378" rel="nofollow noreferrer">this bug</a>. Unfortunately, I haven't been able to find a quick replacement for that dependency (groupId <code>org.mortbay.jetty</code> artifactId <code>jsp-2.1-glassfish</code> version <code>2.1.v20100127</code>) that doesn't introduce the JSTL URI stack trace mentioned above.</p>
  
  <p><strong>UPDATE:</strong> I've found a suboptimal solution. A downgrade to Jetty 7 inspired by <a href="https://stackoverflow.com/questions/2151075/cannot-load-jstl-taglib-within-embedded-jetty-server">this thread</a> now has me up and running. This is great news, but it's discouraging that if I later required any functionality exclusive to Jetty 8 or Jetty 9 that I'd have to scrap this deployment infrastructure. Any insight on JSTL taglib issue in Jetty 9 would still be appreciated.</p>