简体   繁体   English

当类在JBoss 6 WAR WEB-INF / classes文件夹中时,NoClassDefFoundError

[英]NoClassDefFoundError when class is in JBoss 6 WAR WEB-INF/classes folder

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. 我的问题是我有一个Web应用程序构建并作为WAR文件部署到JBoss 6.我的servlet无法在我的应用程序中加载一个类并抛出NoClassDefFoundError。

I confirmed that this class exists in the correct location of the WAR file. 我确认此类存在于WAR文件的正确位置。 All of my application classes exist in the WEB-INF/classes folder, along with my servlet class which executes without a hitch. 我的所有应用程序类都存在于WEB-INF / classes文件夹中,以及我的servlet类,它可以毫不费力地执行。 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? JBoss在JDK 1.6_21上运行,应用程序是用JDK 1.6_24构建的,这应该不是问题吧?

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. 此外,这个应用程序在Eclipse中本地运行良好,当我将WAR文件部署到单独的Tomcat 7和Glassfish 3服务器时,他们都发现这个类没有问题。

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. 我不希望任何人立刻知道什么是错的,如果有人在此之前看到过这样的事情请分享你的经验,或者如果你有很好的技巧或知道好的工具,真的深入到类路径问题然后请分享。

NoClassDefFoundError means that the class was "loaded" but the class definition could not be built. NoClassDefFoundError意味着该类已“加载”但无法构建类定义。 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. 我在AppServers中不止一次看到静态初始化期间的异常未在日志文件中报告。

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). 我在JBoss和WebSphere中看到的另一个原因是Web应用程序正在分发一些与app服务器中的库冲突的库(比如servlet.jar或其他东西)。 Usually the problem is solved by removing the offending library or tweaking the classloading mechanism to "parent first". 通常,通过删除违规库或将类加载机制调整为“父优先”来解决问题。

hope this helps 希望这可以帮助

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

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