title: Maven Embedded Jetty Container fails to load Taglibs: Unable to initialize TldLocationsCache
body: <p>I'm using the Maven Cargo Plugin to startup a Jetty web container for running some integration tests in a separate project module. </p>
  
  <p>The problem i'm battling with occurs when i added taglibs into the jsp pages and tried hitting them from the integration tests. When jetty tries to compile the pages it fails with this error:</p>
  
  <pre><code>org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: null
  </code></pre>
  
  <p>The web app works fine when run in an installed Tomcat container or standalone Jetty run through maven on the command line, so i think  the problem must be down to something to do with how cargo embeds jetty and then how jetty compiles the app. </p>
  
  <p>I've tried running in forked and unforked modes, adding the taglibs to the container classpath, explicitly defining taglibs in web.xml and having no config there...all to no avail.</p>
  
  <p>Here's the test project i'm using to debug:</p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  
  &lt;display-name&gt;taglibs-test&lt;/display-name&gt;
  
  &lt;jsp-config&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;http://java.sun.com/jsp/jstl/core&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/tld/c.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
  &lt;/jsp-config&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the test module pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>http://maven.apache.org/maven-v4_0_0.xsd"></p>
  
  <pre><code>...
  
  &lt;build&gt;
  
          &lt;!-- Integration Test Embedded Servlet Container --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;
              &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;wait&gt;false&lt;/wait&gt;
                  &lt;container&gt;
                      &lt;containerId&gt;jetty6x&lt;/containerId&gt;
                      &lt;type&gt;embedded&lt;/type&gt;
                      &lt;log&gt;${project.build.directory}/log&lt;/log&gt;
                      &lt;dependencies&gt;
                          &lt;dependency&gt;
                              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
                          &lt;/dependency&gt;
                          &lt;dependency&gt;
                              &lt;groupId&gt;taglibs&lt;/groupId&gt;
                              &lt;artifactId&gt;standard&lt;/artifactId&gt;
                          &lt;/dependency&gt;
                      &lt;/dependencies&gt;
                      &lt;systemProperties&gt;
                          &lt;DEBUG&gt;true&lt;/DEBUG&gt;
                      &lt;/systemProperties&gt;
                  &lt;/container&gt;
                  &lt;configuration&gt;
                      &lt;properties&gt;
                          &lt;cargo.servlet.port&gt;8090&lt;/cargo.servlet.port&gt;
                          &lt;cargo.logging&gt;high&lt;/cargo.logging&gt;
                      &lt;/properties&gt;
                      &lt;deployables&gt;
                          &lt;deployable&gt;
                              &lt;groupId&gt;test&lt;/groupId&gt;
                              &lt;artifactId&gt;web&lt;/artifactId&gt;
                              &lt;type&gt;war&lt;/type&gt;
                              &lt;properties&gt;
                                  &lt;context&gt;taglibs-test&lt;/context&gt;
                              &lt;/properties&gt;
                          &lt;/deployable&gt;
                      &lt;/deployables&gt;
                  &lt;/configuration&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;start-container&lt;/id&gt;
                      &lt;phase&gt;test-compile&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;start&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;stop-container&lt;/id&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;stop&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here's the stacktrace from the error:</p>
  
  <pre><code>    2009-01-24 13:53:06.766::WARN:  /taglibs-test/index.jsp: 
  org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: null
      at org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:253)
      at org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:224)
      at org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:526)
      at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:422)
      at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
      at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
      at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
      at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
      at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
  </code></pre>
  
  <p>I've tracked this down to the following lines in jasper's TldLocationsCache:</p>
  
  <pre><code>   private void init() throws JasperException {
          if (initialized) return;
          try {
              processWebDotXml();
              scanJars();
              processTldsInFileSystem("/WEB-INF/");
              initialized = true;
          } catch (Exception ex) {
              throw new JasperException(Localizer.getMessage(
                      "jsp.error.internal.tldinit", ex.getMessage()));
          }
      }
  </code></pre>
  
  <p><a href="http://svn.apache.org/repos/asf/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/compiler/TldLocationsCache.java" rel="nofollow noreferrer">http://svn.apache.org/repos/asf/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/compiler/TldLocationsCache.java</a></p>
  
  <p>Any help is greatly appreciated!!</p>
  
  <p>cam</p>