货物为Jetty 6.x生成上下文XML在哪里?

时间:2012-04-16 08:36:34

标签: maven-2 jetty cargo maven-cargo

我正在尝试实施How to specify jetty-env.xml file for Maven Cargo plugin for Jetty?

中提到的解决方案

然而,我面临更为根本的事情:我的货物根本没有生成任何上下文xml。

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.2.1</version>
    <configuration>
        <!-- Container configuration -->
        <container>
            <containerId>jetty6x</containerId>
            <type>embedded</type>
        </container>
        <!-- Configuration to use with the container or the deployer -->
        <configuration>
            <properties>
                <cargo.servlet.port>${itest.webapp.port}</cargo.servlet.port>
                <cargo.jetty.createContextXml>true</cargo.jetty.createContextXml>
            </properties>
            <deployables>
                <deployable>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>myApp-web</artifactId>
                    <type>war</type>
                    <properties>
                        <context>/myApp</context>
                    </properties>
                </deployable>
            </deployables>
<!--
            <configfiles>
                <configfile>
                    <file>${project.build.outputDirectory}/jetty-env.xml</file>
                    <todir>contexts</todir>
                    <tofile>${jetty6.context}.xml</tofile>
                </configfile>
            </configfiles>
-->
        </configuration>
    </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>
</plugin>

基本思想是,我们提供了一个自定义的context.xml来替换生成的。但是,当我尝试时,我找不到Cargo生成的任何上下文XML(请注意我已经注释了自定义配置文件,并且cargo.jetty.createContextXml为true)

我不确定在设置中是否存在导致未生成上下文的问题,或者在我忽略的某处生成了上下文。我已经在target / cargo /和temp目录下检查了货物扩展了我的WAR,这两个地方都没有包含上下文xml。

(我正在使用Maven 2.2.1,Cargo 1.2.1,JDK 6)

1 个答案:

答案 0 :(得分:0)

我不是100%确定您的问题是什么,但这是我的系统上Jetty6的货物。

Jetty安装所在的目录不是运行时上下文和webapp文件所在的目录。在我的例子中,它们存储在Java临时目录中(即java.io.tmpdir)。在我的Ubuntu系统上,这是/tmp。在此目录下,有一个cargo/conf目录。在/tmp/cargo/conf下,我有一个存储context.xml文件的上下文目录 - 尽管该文件的实际名称永远不会context.xml,但它始终以Web应用程序上下文命名。

就我而言,此文件的名称与我配置货物的上下文相同。这可能是你的问题,因为我注意到你没有像我一样提供上下文:

<deployables>
    <deployable>
       <properties>
         <!-- Web root context URL -->
         <context>${build.appserver.context}</context>
       </properties>
    </deployable>
</deployables>

其次,我还注意到你已经注释掉了将context.xml文件放在正确位置的部分。除非你取消注释,否则这不起作用。

第三,您是否设置了${jetty6.context} Maven属性的值?

第四 - 我认为要实现这一点,您需要使用独立的Jetty配置。这应该不是问题,因为Cargo会自动为您下载并安装它。请在此处查看我的配置:

                      <container>
                          <containerId>jetty6x</containerId>
                          <!-- Using Jetty for build portability so type != "remote". For Jetty
                              would prefer type = "embedded" but we must go with "installed" because jetty-env.xml
                              file would be ignored. See http://jira.codehaus.org/browse/CARGO-861 -->
                          <type>installed</type>
                          <zipUrlInstaller>
                              <url>http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26RC0.zip</url>
                              <installDir>${build.working}</installDir>
                          </zipUrlInstaller>
                          <dependencies>
                              <!-- The following dependencies are added to the servlet container's
                                  classpath as if they were installed by a system admin. In order to be included
                                  here, they need to be listed as dependencies in this pom.xml. -->
                              <dependency>
                                  <groupId>com.h2database</groupId>
                                  <artifactId>h2</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>com.oracle</groupId>
                                  <artifactId>ojdbc5</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>mysql</groupId>
                                  <artifactId>mysql-connector-java</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>net.sourceforge.jtds</groupId>
                                  <artifactId>jtds</artifactId>
                              </dependency>
                          </dependencies>
                      </container>
                      <!-- Do not hang and wait for a client, just do it -->
                      <wait>false</wait>
                      <configuration> <!-- Deployer configuration -->
                          <!-- Running Jetty container with type=installed (e.g. local) so
                              type != "runtime", and we are installing it during this execution for the
                              sake of portability so type != "existing" -->
                          <type>standalone</type>
                          <properties>
                              <!-- Use the port number from settings.xml -->
                              <cargo.servlet.port>${build.appserver.port}</cargo.servlet.port>
                          </properties>
                          <deployables>
                              <deployable>
                                  <properties>
                                      <!-- Web root context URL -->
                                      <context>${build.appserver.context}</context>
                                  </properties>
                              </deployable>
                          </deployables>
                          <configfiles>
                              <configfile>
                                  <file>${basedir}/target/jetty-context.xml</file>
                                  <todir>contexts</todir>
                                  <tofile>${build.appserver.context}.xml</tofile>
                              </configfile>
                          </configfiles>
                      </configuration>