如何解决java.lang.NoClassDefFoundError?
我目前正在开发一个简单的网络项目,为此我使用 Polarion 的 SDK。当尝试使用相应的 *.jar 文件时,Tomcat 7 在启动时抛出以下错误消息:
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NoClassDefFoundError: Lcom/polarion/alm/ws/client/session/SessionWebService;
根据我进行的研究,Java 正在尝试查找 com.java 的实例。 Polarion.ws.client.session.SessionWebService(因此领先L)。我已经检查了类路径中是否有所需的条目 - 它就在那里。
C:\Polarion\polarion\SDK\lib\com.polarion.alm.ws.client\wsclient.jar
到目前为止,我已经不知道哪里出了问题。你有什么想法吗?
多谢! 西蒙
I'm currently working on a simple web project, for which I am using the SDK of Polarion. When trying to work with the according *.jar-Files, Tomcat 7 throws the following error message on start-up:
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NoClassDefFoundError: Lcom/polarion/alm/ws/client/session/SessionWebService;
According to the research I have undertaken, Java is trying to find an instance of com.polarion.ws.client.session.SessionWebService (thus the leading L). I have checked the classpath for the needed entry - it's there.
C:\Polarion\polarion\SDK\lib\com.polarion.alm.ws.client\wsclient.jar
As of now, I've run out of ideas what could have gone wrong. Do you have any ideas?
Thanks a lot!
Simon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该将用于 Web 应用程序的库放在 CLASSPATH 中。您应该将它们放在 web 应用程序的 WEB-INF/lib 中。
You are not supposed to put libraries for use in webapps in the CLASSPATH. You are supposed to put them in WEB-INF/lib in your webapp.
部署和编译是不同的过程。您应该意识到这一点,您可以编译,但如果部署的应用程序无法访问必要的库,您会得到此异常。正如前面的答案所建议的,您应该将必要的库放在 Web 应用程序的 WEB-INF/lib 目录中..
Deployment and compilation are different processes. You should be aware of that, you can compile but if the necessary libraries are not accessible by the deployed application , you would get this exception.. As previous answer suggests, you should put necessary libraries WEB-INF/lib directory of your web application..