开发者

Start a web container then deploy a war with cargo maven2 plugin

I tried to use cargo-maven2-plugin to automate my WAR module deployment for testing.

I wonder how can I start the tomcat server (pre-installed in my machine) and deploy my war to the started server automatically?

Documentation from Cargo project mentions that cargo:start goal can optionally deploy deployables:

http://cargo.codehaus.org/Maven2+plugin#Maven2plugin-gettingstarted

cargo:start Start a container. That task can optionally install and configure a container; it can also optionally deploy deployables (WAR, EAR, etc.) to it.

However, I have no idea how to enable this option to make it deploy deployables when running cargo:start.

Here is my current pom configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <wait>true</wait>
                <container>
                    <containerId>tomcat6x</containerId>
                    <home>${tomcat.home}</home>
                </container>
                <configuration>
                    <type>standalone</type>
                    <home>target/tomcat6x</home>
                </configuration>
                <deployer>
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>my-war</artifactId>
                            <type>war</type>
                        </deployable>
                    </deployables>
                </deployer>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>my-war</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>
</dependencies>

When I run "mvn cargo:start", the tomcat server will be started, however, the my-war deployable 开发者_开发百科won't be deployed. And I have to run "mvn cargo:deploy" from another shell to deploy this war.


OK -- There are a few things going on here:

1) You mention that the Tomcat server is pre-installed on the machine, but yet you have the directory specified in your target directory. This is not a good idea as that will get wiped out after a mvn clean.

2) For pre-installed Tomcat you are not setting the type to existing inside the deployer configuration.

3) Where is your context definition? Do you have a context fragment file or are you using a tomcat.xml file inside the WEB-INF directory in the WAR?

Bottom line a combination of configuration errors are holding you back. Post an updated Maven configuration and addition details about the XML context definition and I can help you further.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜