我正在尝试设置 Maven 以启动 Tomcat(使用 Cargo)并部署我的项目以准备集成测试。
这是我的POM:
< ... >
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.3</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>installed</type>
<home>/Dev/apache-tomcat-6.0.29/</home>
</container>
<configuration>
<type>existing</type>
<home>/Dev/apache-tomcat-6.0.29/</home>
</configuration>
</configuration>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
< .... >
当我清理和构建时,它在我的 Tomcat /lib 目录中找不到 Catalina.jar:
[talledLocalContainer] java.lang.ClassNotFoundException: org.apache.catalina.startup.Catalina
[talledLocalContainer] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[talledLocalContainer] at java.security.AccessController.doPrivileged(Native Method)
[talledLocalContainer] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[talledLocalContainer] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[talledLocalContainer] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[talledLocalContainer] at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:216)
[talledLocalContainer] at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:391)
在启用调试的情况下运行 clean 和 build 时,它显示它正在 tomcat/server/lib 中寻找 Catalina.jar:
[talledLocalContainer] Failed to find Tomcat version, base error [\Dev\apache-tomcat-6.0.29\server\lib\catalina.jar (The system cannot find the path specified)]
[talledLocalContainer] Parsed Tomcat version = [6.x]
[talledLocalContainer] Tomcat 6.x starting...
[talledLocalContainer] Project base dir set to: C:\Users\Colin\Documents\NetBeansProjects\HousingWeb
[talledLocalContainer] Executing 'C:\Program Files\Java\jdk1.6.0_22\jre\bin\java.exe' with arguments:
我的 tomcat 目录如下所示:
- apache-tomcat-6.0.29
+ bin
+ conf
- lib
- Catalina.jar
- [bunch of other .jars]
+ logs
+ temp
+ webapps
+ work
- [other files]
为什么 Cargo 会在 /server/lib 下而不是 /lib 下寻找 Tomcat 的 lib 文件夹?
有没有办法覆盖这种行为?
更新:
在查看了 Tomcat 的不同版本(5.5、6.0、7.0)之后,看起来 5.5 的目录结构有 /server/lib 和 /common/lib,而 6.0 和 7.0 只有 /lib。
Cargo 似乎正在尝试实例化一个 Tomcat 5.5 应用程序。如何将其配置为使用 6.0?