码头 Maven 插件 NoClassDefFoundError
jetty-maven-plugin NoClassDefFoundError
我创建了带有两个 Maven 子模块的 Maven 父模块。 war 输出中的基于 Web 的应用程序部署到 Tomcat directory.The 问题是为了测试 war 文件我必须启动 Tomcat 并测试应用程序.对于这种情况,我决定在父 POM.xml 文件中使用 jetty maven 插件。这是它的样子:
<modules>
<module>hellojavaworld</module>
<module>application</module>
</modules>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/hellojavaworld</contextPath>
</webApp>
<war>c:\apache-tomcat-7.0.64\webapps\hellojavaworld.war</war>
</configuration>
</plugin>
如果我手动启动 Tomcat 并使用 http://localhost:8080/hellojavaworld 它工作正常。
另一方面,当使用
mvn jetty:run-war
有效,但卡在了错误:
HTTP ERROR 500
Problem accessing /hellojavaworld/HelloServlet. Reason:
Server Error
Caused by:
java.lang.NoClassDefFoundError: org/apache/log4j/Level
我知道这个问题很常见,因为缺少 jar。我知道这些罐子放在 c:\apache-tomcat-7.0.64\lib\ 文件夹中。
所以问题是如何告诉码头使用此文件夹作为我的 war 文件的外部 jars?
Note: for the Tomcat itself it runs,there is just problem with jetty.
Jetty 不使用 log4j。
为什么您希望 Web 容器在 servlet 规范之外提供您的 WebApp 日志记录?
See the various ServletContext.log()
methods for actual servlet spec logging
建议:将你的 log4j jar 文件放在你的 webapp 的 WEB-INF/lib/
我创建了带有两个 Maven 子模块的 Maven 父模块。 war 输出中的基于 Web 的应用程序部署到 Tomcat directory.The 问题是为了测试 war 文件我必须启动 Tomcat 并测试应用程序.对于这种情况,我决定在父 POM.xml 文件中使用 jetty maven 插件。这是它的样子:
<modules>
<module>hellojavaworld</module>
<module>application</module>
</modules>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/hellojavaworld</contextPath>
</webApp>
<war>c:\apache-tomcat-7.0.64\webapps\hellojavaworld.war</war>
</configuration>
</plugin>
如果我手动启动 Tomcat 并使用 http://localhost:8080/hellojavaworld 它工作正常。 另一方面,当使用
mvn jetty:run-war
有效,但卡在了错误:
HTTP ERROR 500
Problem accessing /hellojavaworld/HelloServlet. Reason:
Server Error
Caused by:
java.lang.NoClassDefFoundError: org/apache/log4j/Level
我知道这个问题很常见,因为缺少 jar。我知道这些罐子放在 c:\apache-tomcat-7.0.64\lib\ 文件夹中。
所以问题是如何告诉码头使用此文件夹作为我的 war 文件的外部 jars?
Note: for the Tomcat itself it runs,there is just problem with jetty.
Jetty 不使用 log4j。
为什么您希望 Web 容器在 servlet 规范之外提供您的 WebApp 日志记录?
See the various
ServletContext.log()
methods for actual servlet spec logging
建议:将你的 log4j jar 文件放在你的 webapp 的 WEB-INF/lib/