【问题标题】:maven cargo plugin with tomcat6带有tomcat6的maven cargo插件
【发布时间】:2011-09-20 19:03:13
【问题描述】:

我正在尝试设置 maven cargo 插件。我有以下要求:

  • tomcat 6
  • 自定义 server.xml
  • 自定义 context.xml
  • log4j jar 部署到 tomcat lib
  • 如果机器上没有tomcat,请在机器上安装它
  • 绑定到 maven 的安装生命周期阶段以部署战争并重新启动容器
  • 将部署的战争设为 ROOT.war

我关注了以下内容:http://www.java-tutorial.ch/maven/maven-tomcat-deployment-using-cargo。这不是我想要的完整功能集,甚至不能完全工作。这是我得到的:

Can't load log handler "4host-manager.org.apache.juli.FileHandler"
[INFO] [talledLocalContainer] java.lang.ClassNotFoundException: 4host-manager.org.apache.juli.FileHandler

然后当 mvn install 返回时,我执行 ps -ef 并且没有 tomcat 进程。

它还将战争复制到 ROOT.war 但旧的 ROOT/ 目录没有被替换,因此新的 ROOT.war 实际上并没有被部署。

对于“如果还没有安装tomcat”的要求,这似乎应该是绝对简单的,但是当我提供时

 <zipUrlInstaller>
     <url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip</url>
     <extractDir>/usr/local</extractDir>
  </zipUrlInstaller>

然后运行 ​​mvn cargo:install,它会抛出这个:

org.codehaus.cargo.container.ContainerException: Failed to get container installation home as the container has not yet been installed. Please call install() first.

这令人费解。它希望我先调用安装,但我正在调用安装。

想法?

【问题讨论】:

    标签: maven maven-cargo


    【解决方案1】:

    您关注的链接提供了 cargo 1.0.6 的演示。最近可用的版本是 1.1.1,所以我建议你使用最近的,并且子标签有一些变化

    如帖子http://cargo.codehaus.org/Deploying+to+a+running+container 中所述。 ZipUrlInstaller 的子标签有一些变化。

     <!--
            Careful: As described in the ZipUrlInstaller documentation,
            Cargo versions older than 1.1.0 accept only installDir, you therefore
            need to set installDir instead of downloadDir and extractDir.
            -->
    

    http://cargo.codehaus.org/Maven2+Archetypes 之后,尝试使用 maven 原型创建货物示例项目。我建议你使用“Single Webapp Module Archetype”

    设置好maven项目后,可以运行mvn cargo:install -P tomcat6x命令安装tomcat 6。

    “单个 webapp 模块原型”的 pom.xml sn-p 对您很有用。

    <profiles>
        <profile>
            <id>tomcat6x</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.cargo</groupId>
                            <artifactId>cargo-maven2-plugin</artifactId>
                            <configuration>
                            <wait>true</wait>
                                <container>
                                    <containerId>tomcat6x</containerId>
    
                                    <!-- download zip url -->
                                    <zipUrlInstaller>
                                        <url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip</url>
                                        <downloadDir>${project.build.directory}/downloads</downloadDir>
                                        <extractDir>${project.build.directory}/extracts</extractDir>
                                    </zipUrlInstaller>
                                </container>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>
    

    如果等待参数为 true,您可以选择检查服务器是否正在运行。

    【讨论】:

      猜你喜欢
      • 2018-09-05
      • 2011-05-17
      • 2010-11-20
      • 2011-07-06
      • 2011-04-17
      • 2016-11-17
      • 2011-09-13
      • 2014-07-11
      • 2012-06-30
      相关资源
      最近更新 更多