1

我正在使用 Maven Cargo 插件来启动一个 Jetty Web 容器,以便在单独的项目模块中运行一些集成测试。

当我将标记库添加到 jsp 页面并尝试从集成测试中击中它们时,就会出现我正在与之斗争的问题。当 jetty 尝试编译页面时,它会因以下错误而失败:

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

当在已安装的 Tomcat 容器中运行或在命令行上通过 maven 运行的独立 Jetty 中运行时,Web 应用程序运行良好,所以我认为问题一定与货物如何嵌入码头以及码头如何编译应用程序有关。

我试过在分叉和非分叉模式下运行,将标签库添加到容器类路径中,在 web.xml 中明确定义标签库并且那里没有配置......一切都无济于事。

这是我用来调试的测试项目:

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>

以及测试模块 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>

这是错误的堆栈跟踪:

    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)

我已经在 jasper 的 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

任何帮助是极大的赞赏!!

凸轮

4

1 回答 1

0

提交的错误报告:http: //jira.codehaus.org/browse/CARGO-651

于 2009-01-27T10:10:23.400 回答