我正在使用tomcat7-maven-plugin在预集成测试lifecycle phase期间从Maven启动Web应用程序,以便我可以在集成测试阶段在本地运行测试。
我没有在Web应用程序本身上做太多工作,但是对于记录,它使用了使用Spring MVC 3.0捆绑在一起的JSP和Java控制器。
当我在自己的机器上运行Maven(mvn clean verify)时,我看到了插件的以下输出:
[INFO] --- tomcat7-maven-plugin:2.2:run-war-only (start-tomcat) @ MyProject ---
[INFO] Running war on http://localhost:8080/contentmain
[INFO] Using existing Tomcat server configuration at /Users/alexjohnson/MyWorkspace/MyProject/src/test/resources/com/MyCompany/MyProject/ui/automation/tomcat7
Jan 27, 2015 2:18:54 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/alexjohnson/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Jan 27, 2015 2:18:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 27, 2015 2:18:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 27, 2015 2:18:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
Jan 27, 2015 2:18:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 425 ms
Jan 27, 2015 2:18:54 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 27, 2015 2:18:54 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Jan 27, 2015 2:18:55 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
// More startup stuff
这是按预期工作的。请注意,WebappClassLoader.validateJarFile
被调用。另请注意,由于我们未在测试环境中使用这些库,因此需要APR信息消息。
当我在构建服务器上运行Maven(mvn clean verify)时,我看到插件的以下输出:
[INFO] --- tomcat7-maven-plugin:2.2:run-war-only (start-tomcat) @ MyProject ---
[INFO] Running war on http://localhost:8080/contentmain
[INFO] Using existing Tomcat server configuration at /opt/jenkins/workspace/BuildServerWorkspace/src/test/resources/com/MyCompany/MyProject/ui/automation/tomcat7
Jan 27, 2015 2:30:09 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Jan 27, 2015 2:30:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 27, 2015 2:30:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 27, 2015 2:30:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
Jan 27, 2015 2:30:09 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 823 ms
Jan 27, 2015 2:30:09 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 27, 2015 2:30:09 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Jan 27, 2015 2:30:10 PM org.apache.tomcat.util.scan.StandardJarScanner scan
WARNING: Failed to scan JAR [file:/opt/jenkins/BuildServerWorkspace/src/test/resources/com/MyCompany/MyProject/ui/automation/tomcat7/webapps/../../../../../../../../../../../target/MyProject/WEB-INF/lib/openws-1.5.1.jar] from WEB-INF/lib
java.io.FileNotFoundException: /opt/jenkins/BuildServerWorkspace/src/test/resources/com/MyCompany/MyProject/ui/automation/tomcat7/webapps/../../../../../../../../../../../target/MyProject/WEB-INF/lib/openws-1.5.1.jar (No such file or directory)
// Hundreds more FileNotFoundExceptions for JAR files.
这不正在运作。请注意,此时调用StandardJarScanner.scan
。另请注意,缺少的JAR文件似乎是在本地计算机上以相同的相对路径构建期间创建的(从webapps出来的11个目录和目标目录中的5个目录)。我相信所有这些JAR文件都是针对第三方Maven依赖项。
我已阅读官方JavaDocs,但找不到WebappClassLoader
或StandardJarScanner
的有用说明。我真正可以收集的是,当Tomcat启动时,它们都用于从JAR文件加载类。
我想知道的事情:
答案 0 :(得分:0)
查看此问题https://issues.apache.org/jira/browse/MTOMCAT-239 听起来像jenkins的一些奇怪的路径,我无法弄清楚为什么......
答案 1 :(得分:0)
WebAppClassLoader和StandardJarScanner是苹果和橘子。 StandardJarScanner始终在WebAppClassLoader之前运行,但只在出现问题时才生成日志语句。这意味着StandardJarScanner日志语句出现在失败构建中与传递构建中的WebAppClassLoader日志语句相同的位置。
由于我错误地阅读了这些日志语句,我最终提出了错误的问题。我原来的问题仍然存在。我在Why is Tomcat throwing FileNotFoundExceptions for existing JAR files?打开了一个新问题。