0

Maven uber war cargo-maven2-plugin を使用して、2 つの war と web.xml ファイルをマージしようとしています。すべてのタグ (フィルター、サーブレット) のマージは希望どおりに行われますが、<context-param>RHS の web.xml で定義された最初の要素のみをマージするため、LHS の web.xml のすべての context-param を保持したいすべての<context.param>要素をマージします。 RHS の私の web.xml で定義されています。これが私のコードです

RHS の web.xml

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- ** SPRING ** -->
    <context-param>
        <param-name>contextInitializerClasses</param-name>
        <param-value>com.myorg.context.MyApplicationContextInitializer</param-value>
    </context-param>

   <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:conf/spring/*.xml</param-value>
    </context-param>

   <context-param>
        <description>Location(s) to search for the Log4J config file</description>
        <param-name>log4jConfigLocation</param-name>
        <param-value>file:/dir/path/log4j.xml /WEB-INF/log4j.xml</param-value>
    </context-param>

    <context-param>
        <description>
            Boolean flag indicating whether internal Log4J debugging statements should be written. Log4J
            will write debugging messages to System.out and error messages to System.err.
        </description>
        <param-name>log4jConfigDebug</param-name>
        <param-value>false</param-value>
    </context-param>

**

  • merge.xml

**

    <?xml version="1.0"?>
<uberwar>
    <wars>
        <war>org.forgerock.openam:openam-server</war>
        <war>com.myorg.xyz.addons:my-sso-addons-web</war>
    </wars>

     <merges>
        <merge>
            <type>web.xml</type>
            <parameters>
                <default>

                    <!-- Preserve execution order of filter-mappings -->
                    <tag name="context-param">
                        <strategy name="ChooseByName">
                            <default>
                                <strategy name="Preserve" />
                            </default>
                            <choice name="contextInitializerClasses">
                                <strategy name="Overwrite" />
                            </choice>
                            <choice name="contextConfigLocation">
                                 <strategy name="Overwrite" />
                            </choice>
                            <choice name="log4jConfigLocation">
                                <strategy name="Overwrite" />
                            </choice>
                        </strategy>
                    </tag>

                    <tag name="filter-mapping">
                        <strategy name="Preserve"/>
                    </tag>

                </default>
            </parameters>
        </merge>
    </merges>
</uberwar>

pom.xml

  <!-- other entries are here -->
<packaging>uberwar</packaging>

    <build>
        <plugins>
            <!-- merges openam-server with openam-addons-web-common -->
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <!-- merges the wars -->
                    <descriptor>src/assembly/merge.xml</descriptor>
                    <configuration>
                        <type>existing</type>
                        <home>${jboss.home}/aclsso</home>
                    </configuration>
                    <deployer>
                        <type>installed</type>
                    </deployer>
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <type>war</type>
                            <properties>
                                <context>openam</context>
                            </properties>
                        </deployable>
                    </deployables>
                </configuration>
            </plugin>

        </plugins>
    </build>
4

1 に答える 1

0

この特定のケースの問題は、xmlns のバージョンと、web.xml の先頭にあるスキーマの場所の違いでした。最初の戦争のバージョンは 2.4 でしたが、2 番目の戦争のバージョンは 3.0 でした。以下を使用して両方の web.xml スキーマの同期を維持すると、問題が解決されました (フィルター、サーブレット タグをマージし、すべての context-param タグのマージに失敗した理由はわかりません)。

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

于 2016-03-17T18:03:32.767 に答える