2

Java6でJSP2.1、Servlets 2.5、JSTL 1.2を使用しているWebアプリがあります。maven-jetty-plugin6.1.1rc1を使用して、問題なくテストを行っています。このリンクから:http ://docs.codehaus.org/display/JETTY/JSP+2.0+v+JSP+2.1、JDK5+で正常に動作している場合にjetty6がJSP2.1を選択することを理解しています。

これは、アプリケーション戦争の私のpom.xmlからの関連セクションです。

<!--servlet & javax-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
    </dependency> 

次に、cargoとjetty6xを組み込んだ自動統合テストを設定したいと思います。コンテナはエラーなしで正常に起動します。ただし、JSPをレンダリングできません。これは私が得る例外であり、私が知る限り、JSP-2.1の代わりにJSP-2.0implが使用されているためです。

(TagLibraryInfoImpl.java:547) - Unknown element (deferred-value) in attribute

Caused by: java.lang.NoSuchMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext; at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:140)

これが私の貨物設定です:

<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.1</version>
<configuration>
    <container>
        <containerId>jetty6x</containerId>
        <type>embedded</type>
    </container>
    <configuration>
        <deployables>
            <deployable>
                <groupId>groupId</groupId>
                <artifactId>artifact</artifactId>
                <type>war</type>
            </deployable>
        </deployables>
    </configuration>
    <wait>${cargo.wait}</wait>
</configuration>
<executions>
    <execution>
        <id>start-container</id>
        <phase>pre-integration-test</phase>
        <goals>
            <goal>start</goal>
        </goals>
    </execution>
    <execution>
        <id>stop-container</id>
        <phase>post-integration-test</phase>
        <goals>
            <goal>stop</goal>
        </goals>
    </execution>
</executions>

貨物のjetty6xコンテナも桟橋のv6.1.1rc1を使用しているため、貨物が突堤を使用している方法と関係があるはずです。カーゴは、Maven依存関係メカニズムを使用する代わりに、コンテナー依存関係のバージョンをハードコーディングしていることを知っています(おそらく正当な理由で、jira-> CARGO-571)

だから私の質問は:他の誰かが貨物と突堤6xが埋め込まれたJSP2.1を使用することに成功しましたか?それを機能させるための提案はありますか?

どんな助けでも大歓迎です!

4

1 に答える 1

1

OK、なんとかこれを理解することができました。貨物メーリングリストからのこの投稿は役に立ちました:http: //old.nabble.com/Jetty6-version-with-maven-plugin-td16722550.html。カーゴを使用してコンテナのクラスパスをカスタマイズする方法について説明しましたが、このアプローチを採用する場合は、すべての依存関係を手動で指定する必要があります。

貨物ソースから、これらはjetty6xコンテナにデフォルトで使用される依存関係であることがわかりました。

jetty6xDependencies.add(new Dependency("org.mortbay.jetty", "jsp-api-2.0", "6.1.1rc1"));
    jetty6xDependencies.add(new Dependency("org.mortbay.jetty", "servlet-api-2.5", "6.1.1rc1"));
    jetty6xDependencies.add(new Dependency("org.mortbay.jetty", "jetty", "6.1.1rc1"));
    jetty6xDependencies.add(new Dependency("org.mortbay.jetty", "jetty-util", "6.1.1rc1"));
    jetty6xDependencies.add(new Dependency("org.mortbay.jetty", "jetty-naming", "6.1.1rc1"));
    jetty6xDependencies.add(new Dependency("org.mortbay.jetty", "jetty-plus", "6.1.1rc1"));
    jetty6xDependencies.add(new Dependency("ant", "ant", "1.6.5"));
    jetty6xDependencies.add(new Dependency("commons-el", "commons-el", "1.0"));
    jetty6xDependencies.add(new Dependency("tomcat", "jasper-compiler", "5.5.15"));
    jetty6xDependencies.add(new Dependency("tomcat", "jasper-runtime", "5.5.15"));
    jetty6xDependencies.add(new Dependency("tomcat", "jasper-compiler-jdt","5.5.15"));
    jetty6xDependencies.add(new Dependency("javax.mail", "mail", "1.4"));
    jetty6xDependencies.add(new Dependency("javax.activation", "activation", "1.1"));
    jetty6xDependencies.add(new Dependency("geronimo-spec", "geronimo-spec-jta", "1.0.1B-rc4"));
    jetty6xDependencies.add(new Dependency("xerces", "xercesImpl","2.6.2"));
    jetty6xDependencies.add(new Dependency("xerces", "xmlParserAPIs","2.6.2"));
    jetty6xDependencies.add(new Dependency("commons-logging", "commons-logging","1.0.4"));
    jetty6xDependencies.add(new Dependency("log4j", "log4j", "1.2.14"));

問題のあるものは、JSP 2.0を使用しているため、Tomcatのものです。したがって、クラスパスを設定するときは、それらを除外し、JSP-2.1を含める必要があります。

<dependencies>
<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jsp-2.1</artifactId>
    <version>6.1.1rc1</version>
</dependency>

<dependency>
    <groupId>org.eclipse.jdt</groupId>
    <artifactId>core</artifactId>
    <version>3.1.1</version>
</dependency>

したがって、全体の構成は次のとおりです。

<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.1</version>
<configuration>
    <container>
        <containerId>jjetty6x</containerId>
        <type>embedded</type>
        <implementation>
            org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer
        </implementation>
        <timeout>500000</timeout>
        <dependencies>
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jsp-api-2.1</artifactId>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </dependency>
            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </dependency>
            <dependency>
                <groupId>xerces</groupId>
                <artifactId>xmlParserAPIs</artifactId>
            </dependency>
            <dependency>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
            </dependency>
            <dependency>
                <groupId>geronimo-spec</groupId>
                <artifactId>geronimo-spec-jta</artifactId>
            </dependency>
            <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
            </dependency>
            <dependency>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </dependency>
            <!--replaced these:-->
            <!--<dependency>
                <groupId>tomcat</groupId>
                <artifactId>jasper-compiler</artifactId>
            </dependency>
            <dependency>
                <groupId>tomcat</groupId>
                <artifactId>jasper-runtime</artifactId>
            </dependency>
            <dependency>
                <groupId>tomcat</groupId>
                <artifactId>jasper-compiler-jdt</artifactId>
            </dependency>-->
            <!--with this:-->
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jsp-2.1</artifactId>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jdt</groupId>
                <artifactId>core</artifactId>
            </dependency>
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>servlet-api-2.5</artifactId>
            </dependency>
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty</artifactId>
            </dependency>
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-util</artifactId>
            </dependency>
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-naming</artifactId>
            </dependency>
            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-plus</artifactId>
            </dependency>
            <dependency>
                <groupId>ant</groupId>
                <artifactId>ant</artifactId>
            </dependency>
            <dependency>
                <groupId>commons-el</groupId>
                <artifactId>commons-el</artifactId>
            </dependency>
        </dependencies>
    </container>
    <configuration>
        <deployables>
            <deployable>
                <groupId>gruopId</groupId>
                <artifactId>artifact</artifactId>
                <type>war</type>
            </deployable>
        </deployables>
        <implementation>
            org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration
        </implementation>
</configuration>
<executions>
    <execution>
        <id>start-container</id>
        <phase>pre-integration-test</phase>
        <goals>
            <goal>start</goal>
        </goals>
    </execution>
    <execution>
        <id>stop-container</id>
        <phase>post-integration-test</phase>
        <goals>
            <goal>stop</goal>
        </goals>
    </execution>
</executions>

すべての依存関係を2回指定する必要があることに注意してください。1回はプラグインで、もう1回はプロジェクトの依存関係として指定します。最初のスニペットからバージョンを取得できます。

于 2010-06-24T10:03:03.393 に答える