我正在尝试设置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 and 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下寻找Tomcat的lib文件夹,而不是直接在/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?
WARNING: Problem with directory [C:\Users\Colin\Documents\NetBeansProjects\HousingWeb\target\cargo\configurations\tomcat6x\common\lib], exists: [false]
。 - Planky