在Eclipse构建路径中使用用户库时,ClassNotFoundException [英] ClassNotFoundException when using User Libraries in Eclipse build path

查看:128
本文介绍了在Eclipse构建路径中使用用户库时,ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse 3.7(STS)与Tomcat 7在IDE中运行。我创建了一个新的动态Web项目,并将单个JSP文件添加到Web内容根文件夹。我可以运行Tomcat并从Eclipse中访问JSP。没有任何问题。



我已经从用户库添加了几个第三方JAR到项目(我不是使用maven或auto依赖管理)。在JSP中,我引用了项目的JAR文件中的一个类,我可以编译这个没有问题,但是当我在Tomcat上部署时,JSP会抛出ClassNotFoundException。显然,Tomcat从我的库设置中找不到JAR。我尝试为Tomcat Server创建一个Run As配置,我设置类路径以匹配项目的类路径设置,但是我仍然得到相同的classnotfound问题。



我可以通过手动将所有项目JAR复制到WEB-INF / lib目录来解决问题,因此webapp可以找到所有的依赖关系,但这是荒谬的,我不期望这是一个维护噩梦的解决方案。



我错过了什么吗?

解决方案

在项目的属性中,转到部署程序集。在那里添加您已手动添加为用户库的构建路径条目。它将以部署的WAR的 / WEB-INF / lib 结尾。




I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.

I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.

I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.

Am I missing something?

解决方案

In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.

这篇关于在Eclipse构建路径中使用用户库时,ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆