带有 tomcat6 的 Maven 货物插件

发布于 2024-11-16 21:03:26 字数 1366 浏览 2 评论 0 原文

我正在尝试设置 Maven 货物插件。我有以下要求:

  • 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.

这是令人费解的。它要我先调用安装,但我正在调用安装。

有想法吗?

I'm trying to setup maven cargo plugin. I have the following requirements:

  • tomcat 6
  • custom server.xml
  • custom context.xml
  • log4j jar deployed to tomcat lib
  • install tomcat on the machine if it's not there already
  • tie to maven's install lifecycle phase to deploy a war and restart the container
  • make the deployed war be ROOT.war

I've followed the following: http://www.java-tutorial.ch/maven/maven-tomcat-deployment-using-cargo. This isn't the complete feature set I want, and even it doesn't work entirely. This is what I get:

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

And then when mvn install returns I do ps -ef and there's no tomcat process.

Also it copies the war to ROOT.war but the old ROOT/ directory is not replaced so the new ROOT.war doesn't actually get deployed.

For the "install tomcat if not already there" requirement, it seems like this should be absolutely straightforward, yet when I provide

 <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>

and run mvn cargo:install, it throws this:

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

Which is puzzling. It wants me to call install first, but I AM calling install.

Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁虫ゝ 2024-11-23 21:03:26

您关注的链接提供了 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.
        -->

尝试使用 Maven archetype 在帖子 http://cargo.codehaus.org/Maven2+Archetypes 之后创建货物示例项目。我建议您使用“Single Webapp Module Archetype”

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

“单个 webapp 模块原型”的 pom.xml 片段可能对您有用。

<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>

其中 wait 参数 true 将为您提供检查服务器是否正在运行的选项。

Link you followed has given demo for cargo 1.0.6. Recent version available is 1.1.1 so I suggest you to use recent and there is certain changes in child tags

As described in post http://cargo.codehaus.org/Deploying+to+a+running+container. There are ceratin changes in child tags of 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.
        -->

Try to use maven archetype to create cargo sample project following post http://cargo.codehaus.org/Maven2+Archetypes. I suggest you to user "Single Webapp Module Archetype"

After setting up maven project, You can install tomcat 6 running mvn cargo:install -P tomcat6x command.

pom.xml snippet of "single webapp module archetype" which can be useful for you.

<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>

where wait parameter true will give you option to check whether server is running or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文