NoClassDefFoundError:如何确定未找到哪个类定义
我正在尝试运行 tomcat 应用程序,但是当我尝试转到该应用程序时,我得到:
java.lang.NoClassDefFoundError:无法初始化类 ysl.util.Utils ysl.util.Utils.executeQuery(Utils.java:186)
ysl.util.Utils.getProperty(Utils.java:395)
ysl.util.Utils.getProperty(Utils.java:383)
ysl.util.YslMachineProperties.init(YslMachineProperties.java:76)
ysl.util.YslMachineProperties.getTomcatImagesDirectory(YslMachineProperties.java:109)
org.apache.jsp.YSLLogin_jsp._jspService(YSLLogin_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
我在网上发现了许多对此问题的引用 - 大多数人说在编译应用程序时有一个可用的类,但在运行时不可用我需要在 java 类路径中添加一些内容才能找到它。但我如何确定缺少哪个类呢?
错误消息表明 Utils 类无法初始化,但堆栈跟踪显示我们进入了类中的第二个方法,因此我认为该类已经初始化。当然,这不是找不到定义的类,因为我们在堆栈跟踪中有行号信息。
触发错误的方法如下所示:
static public ResultSetexecuteQuery(String queryString) throws SQLException {
返回 dbConnPool.executeQuery(queryString);
有什么建议吗?
I am attempting to run a tomcat application, but when I try to go to the application I get:
java.lang.NoClassDefFoundError: Could not initialize class ysl.util.Utils
ysl.util.Utils.executeQuery(Utils.java:186)
ysl.util.Utils.getProperty(Utils.java:395)
ysl.util.Utils.getProperty(Utils.java:383)
ysl.util.YslMachineProperties.init(YslMachineProperties.java:76)
ysl.util.YslMachineProperties.getTomcatImagesDirectory(YslMachineProperties.java:109)
org.apache.jsp.YSLLogin_jsp._jspService(YSLLogin_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
I have found many references to this problem on the web - most say there was a class available when the application was compiled that is not available at run time and that I need to add something to the java classpath to find it. But how can I determine what class is missing?
The error message says that the Utils class could not be initialized, yet the stacktrace shows that we are into the second method in the class, so I would think that the class was already initialized. And certainly that is not the class whose definition can't be found, since we have line number information in the stacktrace.
The method which is triggering the error looks like this:
static public ResultSet executeQuery(String queryString) throws SQLException {
return dbConnPool.executeQuery(queryString);
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最有可能的是 Utils 类正在尝试使用在静态初始化期间不可用的另一个类(这将是 @BalusC 指出的根本原因)。加载该类失败也会导致 Utils 失败,因此即使定义了 Utils,它的依赖项也没有定义。
Most likely the Utils class is trying to use another class that is unavailable during static initialization (that would be the root cause that @BalusC pointed out). The failure to load that class causes Utils to fail as well, so even though Utils is defined, its dependencies are not.
如果您使用的是 oracle (ex Sun) java,请尝试运行:
more options under http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html
您将看到加载了哪些类。
If you are using oracle (ex Sun) java, try running:
more options under http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html
You will see what classes were loaded.