gpt4 book ai didi

java - Tomcat7设置Class路径解决NoClassDefNotFound错误

转载 作者:行者123 更新时间:2023-11-28 22:20:25 24 4
gpt4 key购买 nike

我最近将我在 eclipse 中构建的 Web 应用程序部署到 AWS ec2 实例。在 eclipse 中工作正常,但在我的服务器上出现 NoClassDefNotFound 错误。我在我的 servlet 中编写了一个测试主要方法,并且能够通过运行

来消除错误
java -cp .:(class paths to all imported classes). packageName.myservlet

所以我的问题是如何配置 tomcat7 以包含我所做的类路径以使我的 servlet 正常运行,谢谢。

Apr 06, 2014 10:53:37 PM org.apache.catalina.startup.HostConfig deleteRedeployResources
INFO: Undeploying context [/ArtGallery]
Apr 06, 2014 10:53:52 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with JAR file [/usr/share/java/tomcat7/log4j.jar], exists: [false] canRead:[false]
Apr 06, 2014 10:53:52 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with JAR file [/usr/share/java/tomcat7/log4j.jar], exists: [false] canRead:[false]
Apr 06, 2014 10:53:52 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with JAR file [/usr/share/tomcat7/usr/lib/jvm/jre/lib/j2ee.jar]exists:[false],canRead:[false]
Apr 06, 2014 10:53:52 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory[/usr/share/tomcat7/usr/share/tomcat7/webapps/ArtGallery/WEB-INF/lib], exists: [false], isDirectory: [false], canRead: [false]
Apr 06, 2014 10:53:52 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with JAR file [/usr/share/tomcat7/usr/lib/jvm/jre/lib/j2ee.jar], exists: [false], canRead: [false]
Apr 06, 2014 10:53:52 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory[/usr/share/tomcat7/usr/share/tomcat7/webapps/ArtGallery/WEB-INF/lib], exists: [false], isDirectory: [false], canRead: [false]
Apr 06, 2014 10:53:53 PM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
SEVERE: Exception processing Global JNDI Resources
javax.naming.NamingException: The markup in the document following the root element must be well-formed.

这是我在 catalina.out 中发现的一些可疑警告,下面是我可以用来让 servlet 运行我的测试主要方法的内容。

java -classpath .:/usr/lib/jvm/jre/lib/j2ee.jar:/usr/share/tomcat7/webapps/ArtGallery/WEB-INF/lib/* ArtworkServlet/ArtworkDB

最佳答案

查看日志文件,您的 tomcat 安装似乎存在问题。有关详细信息,请参阅评论。

作为暴力解决方案,我建议重新安装 tomcat。

使用类路径不是解决问题的正确方法

关于java - Tomcat7设置Class路径解决NoClassDefNotFound错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22899905/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com