英文:
How can one get a NoClassDefFound for a JDK class/jar?
问题
在更新依赖项版本时,我开始遇到一个java.lang.NoClassDefFoundError: javax/net/ssl/SSLSession
错误。javax.net.ssl.SSLSession是在rt.jar中找到的JDK类。更新依赖项会导致找不到JDK jar文件吗?
编辑:对我来说,答案是这样的,这样的依赖变更不能导致这样的结果。当时并不知道有一个基础镜像变更是导致这个问题的原因。
我会保留这个问题,因为我认为回复和评论对于后来遇到类似问题的人可能会有帮助。对于这样的人,我建议:仔细检查你的类路径,然后再检查一下你的jdk目录。
英文:
In updating a version of a dependency, I began getting a java.lang.NoClassDefFoundError: javax/net/ssl/SSLSession
. javax.net.ssl.SSLSession is a JDK class found in rt.jar. How can updating a dependency cause a JDK jar to not be found?
EDIT: the answer for me is that such a dep change can't cause this result. There was a base image change that was not known at the time of asking that was responsible.
I am leaving the question up as I think the replies and comments could be helpful to someone coming here for a similar issue. To such people I recommend: double check you classpath and double check your jdk directory.
答案1
得分: 1
请注意您并非在查看ClassNotFoundException
。
ApiDoc 关于 NoClassDefFoundError
的说明:
如果 Java 虚拟机或 ClassLoader 实例尝试加载类的定义(作为正常方法调用的一部分或作为使用新表达式创建新实例的一部分)并且找不到类的定义,则会抛出此异常。
在当前执行的类编译时,所搜索的类定义是存在的,但现在无法找到该定义。
英文:
Be aware you are not looking at a ClassNotFoundException
.
The ApiDoc states about NoClassDefFoundError
:
Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论