Maven Embedded Jetty Container fails to load Taglibs: Unable to initialize TldLocationsCache

I'm using the Maven Cargo Plugin to startup a Jetty web container for running some integration tests in a separate project module.

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:

org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: null

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.

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.

Here's the test project i'm using to debug:

web.xml

<?xml version='1.0' encoding='UTF-8'?>
<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">

<display-name>taglibs-test</display-name>

<jsp-config>
    <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>
</jsp-config>

And the test module pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/maven-v4_0_0.xsd">

...

<build>

        <!-- Integration Test Embedded Servlet Container -->
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <configuration>
                <wait>false</wait>
                <container>
                    <containerId>jetty6x</containerId>
                    <type>embedded</type>
                    <log>${project.build.directory}/log</log>
                    <dependencies>
                        <dependency>
                            <groupId>javax.servlet</groupId>
                            <artifactId>jstl</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>taglibs</groupId>
                            <artifactId>standard</artifactId>
                        </dependency>
                    </dependencies>
                    <systemProperties>
                        <DEBUG>true</DEBUG>
                    </systemProperties>
                </container>
                <configuration>
                    <properties>
                        <cargo.servlet.port>8090</cargo.servlet.port>
                        <cargo.logging>high</cargo.logging>
                    </properties>
                    <deployables>
                        <deployable>
                            <groupId>test</groupId>
                            <artifactId>web</artifactId>
                            <type>war</type>
                            <properties>
                                <context>taglibs-test</context>
                            </properties>
                        </deployable>
                    </deployables>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <id>start-container</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stop-container</id>
                    <phase>package</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Here's the stacktrace from the error:

    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)

I've tracked this down to the following lines in jasper's TldLocationsCache:

   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()));
        }
    }

http://svn.apache.org/repos/asf/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/compiler/TldLocationsCache.java

Any help is greatly appreciated!!

cam

Answers


Bug report filed: http://jira.codehaus.org/browse/CARGO-651


Need Your Help

Verify in app purchase receipt without external server?

iphone objective-c ios

I would like to verify an in-app purchase receipt by sending a JSON to buy.itunes.apple.com/verifyReceipt, but im not sure how. I can find lots of tutorials on how to do it with a php server, but I...

Issues querying google sitemap.xml with Linq to XML

c# linq-to-xml google-sitemap

I have a Linq-2-XML query that will not work if a google sitemap that I have created has its urlset element populated with attributes but will work fine if there are no attributes present.