简体   繁体   English

Eclipse中Tomcat下的Java ClassNotFoundException

[英]Java ClassNotFoundException under Tomcat in Eclipse

I have been all over existing posts that deal with the ClassNotFoundException running a Java web app under Tomcat in Eclipse. 我一直在处理在Eclipse中Tomcat下运行Java Web应用程序的ClassNotFoundException的现有帖子。

I am unable to provide source code and configuration artifacts because I am working on a proprietary code base. 我无法提供源代码和配置工件,因为我正在开发专有代码库。 However, through trial and error I have boiled the problem down to its basic elements. 然而,通过反复试验,我把问题归结为其基本要素。

I have project packaged by Maven as a WAR. 我将Maven打包的项目作为WAR。 There are a number of other projects in the workspace on which the primary package depends. 主工具包所依赖的工作空间中有许多其他项目。 This arrangement has been working fine: I can deploy the WAR and the JARs it depends on under a Tomcat instance in Eclipse and the application runs and I can debug it. 这种安排一直很好:我可以在Eclipse中的Tomcat实例下部署WAR和它依赖的JAR,应用程序运行,我可以调试它。

Now I have created a new project that for the moment contains a single public class with a public constructor. 现在我创建了一个新项目,目前包含一个带有公共构造函数的公共类。 The maven build works fine and the Eclipse compile workspace works fine. maven构建工作正常,Eclipse编译工作区正常工作。 However, when I deploy to Tomcat and exercise an execution path that instantiates the class in the new project, I get a ClassNotFoundException. 但是,当我部署到Tomcat并执行在新项目中实例化类的执行路径时,我得到一个ClassNotFoundException。

I have checked the following items: 我检查了以下项目:

  • The Web Deployment Assembly for the primary package's project specifies WEB-INF/lib/ as the Deploy Path for the new project; 主程序包项目的Web部署程序集将WEB-INF / lib /指定为新项目的部署路径;
  • The JAR for the new project does in fact end up in the WEB-INF/lib/ folder under the actual deployment folder; 新项目的JAR实际上最终位于实际部署文件夹下的WEB-INF / lib /文件夹中;
  • When I do a clean and publish on the server, the contents of the actual deployment folder do in fact get nuked and get repopulated with all the right JARs; 当我在服务器上进行干净并发布时,实际部署文件夹的内容确实会被破解并重新填充所有正确的JAR;
  • The new project's JAR as I find it the WEB-INF/lib in the deployment folder does in fact contain the class I am trying to instantiate; 新项目的JAR,因为我发现部署文件夹中的WEB-INF / lib确实包含我试图实例化的类;
  • The Tomcat log (which includes the startup cycle) contains no errors other than than the ClassNotFoundException; Tomcat日志(包括启动周期)除了ClassNotFoundException之外不包含任何错误;
  • I have re-done the Maven build and applied Maven build to the Eclipse projects numerous times; 我重新完成了Maven构建,并多次将Eclipse Maven构建应用到Eclipse项目中;
  • I have cleaned and rebuilt in Eclipse numerous times; 我曾多次在Eclipse中清理和重建;
  • I have cleaned and republished to the web server in Eclipse countless times; 我已经无数次地清理并重新发布到Eclipse中的Web服务器;
  • I have created several new server instances. 我创建了几个新的服务器实例。

Based on existing discussions of the ClassNotFoundException-in-Tomcat problem, these are the only things I have found to check. 基于ClassNotFoundException-in-Tomcat问题的现有讨论,这些是我发现要检查的唯一内容。 What else should I be looking into? 我还应该研究什么呢?

Thanks for your help. 谢谢你的帮助。

Even for me the same problem has occurred .... I have clean the Tomcat and the Tomcat work directory and run the project again it worked fine... 即使对我来说也出现了同样的问题....我已经清理了Tomcat和Tomcat工作目录并再次运行项目它运行良好...

This may happen because of the cache, sometimes which is not cleaned properly while building the application. 这可能是因为缓存,有时在构建应用程序时未正确清理。

sometimes deleting the project from the eclise and importing it again doing it from scratch will also clear the problem 有时从eclise中删除项目并从头开始再次导入它也可以解决问题

I'm not sure what exactly was wrong. 我不确定到底出了什么问题。 However, I ended up resolving this issue by removing the project from the workspace, re-creating it from scratch, and importing my class into the re-created project. 但是,我最终解决了这个问题,方法是从工作区中删除项目,从头开始重新创建项目,然后将我的类导入重新创建的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM