当类位于 JBoss 6 WAR WEB-INF/classes 文件夹中时出现 NoClassDefFoundError

发布于 2024-10-29 06:19:52 字数 426 浏览 4 评论 0原文

我的问题是,我将Web应用程序构建和部署为JBOSS 6的战争文件。我的Servlet无法在应用程序中加载类,并抛出NoclassDeffoundError。

我确认此类存在于战争文件的正确位置。我的所有应用程序类都存在于Web-Inf/类文件夹中,以及我的Servlet类无需挂接。实际上,似乎只是这个类别不在类路径上,因为应用程序的其他方面运行良好。

JBOSS在JDK 1.6_21上运行,该应用程序是使用JDK 1.6_24构建的,这不是问题吗?

此外,此应用程序在Eclipse内部在本地运行良好,当我将战争文件部署到单独的Tomcat 7和Glassfish 3服务器时,他们俩都发现了这一类而没有问题。

我没想到有人会立即知道出了什么问题,如果有人看到这样的事情,请分享您的经验,或者如果您有很好的提示或知道真正了解Class Path问题的好工具,请分享。

My problem is that I have a web application built and deployed as a WAR file to JBoss 6. My servlet fails to load a class in my app and throws a NoClassDefFoundError.

I confirmed that this class exists in the correct location of the WAR file. All of my application classes exist in the WEB-INF/classes folder, along with my servlet class which executes without a hitch. In fact, it seems it is just this one class that is not on the classpath because other aspects of the application run great.

JBoss is running on JDK 1.6_21, the app was built with JDK 1.6_24, this shouldn't be an issue right?

Further this app runs fine locally within Eclipse, and when I deploy the WAR file to a seperate Tomcat 7 and Glassfish 3 server they both find this class without a problem.

I am not expecting anybody to just instantly know whats wrong, if anybody has seen something like this happen before then please share your experiences, or if you have good tips or know of good tools for REALLY getting deep into classpath issues then please share.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清音悠歌 2024-11-05 06:19:52

NoClassDefFoundError 表示类已​​“加载”,但无法构建类定义。通常在类的静态初始化出现异常时发生。
我在AppServers中不止一次看到日志文件中没有报告静态初始化期间的异常。

检查失败的类的静态块和静态属性的初始化,以查找异常的潜在原因。

我在 JBoss 和 WebSphere 中看到的另一个原因是 Web 应用程序正在分发一些与应用程序服务器中的库冲突的库(例如 servlet.jar 或其他东西)。通常,通过删除有问题的库或将类加载机制调整为“父级优先”来解决问题。

希望这有帮助

NoClassDefFoundError means that the class was "loaded" but the class definition could not be built. It usually happen when there is an exception in the static initialization of the class.
I have seen more than once in AppServers that exceptions during the static initialization is not reported in the log file.

Check the static blocks and initialization of static attributes of the class that is failing for potential causes of exceptions.

Another cause that I have seen in JBoss and WebSphere is that the web application is distributing some library that conflicts with a library in the app server (like servlet.jar or something). Usually the problem is solved by removing the offending library or tweaking the classloading mechanism to "parent first".

hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文