作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近将我在 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/
我是一名优秀的程序员,十分优秀!