开发者

maven cargo plugin with tomcat6

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.Co开发者_如何学GontainerException: 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜