gpt4 book ai didi

java - 在 64 位机器上运行时出现 NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-01 15:14:05 24 4
gpt4 key购买 nike

在 64 位计算机上启动服务时出现以下异常。但代码在 32 位机器上运行良好。

java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisitor
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.springframework.context.support.GenericApplicationContext.<init (GenericApplicationContext.java:103)
at org.springframework.context.support.GenericApplicationContext.<init>(GenericApplicationContext.java:125)
at org.springframework.coral.CoralApplicationContext.<init>(CoralApplicationContext.java:41)
at org.springframework.coral.CoralApplicationContext.<init>(CoralApplicationContext.java:35)
at org.springframework.coral.DisposableApplicationContext.<init>(DisposableApplicationContext.java:16)
at com.amazon.coral.spring.Launcher.<init>(Launcher.java:85)
at com.amazon.coral.spring.Launcher.main(Launcher.java:56)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.commons.EmptyVisitor
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 19 more

最佳答案

除非您(或您使用的库)使用 native 代码,否则底层平台很少会成为 Java 程序中的问题。

来自 NoClassDefFoundError 的 Javadoc (http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/NoClassDefFoundError.html):

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.

因此,在编译代码时它就存在,但当您尝试在其他地方运行它时,它就不再存在。最典型的原因是类路径设置不正确,通常是因为包含相关类的 jar 文件不在类路径中。修改您的类路径定义并重新运行。

如果您不熟悉类路径的工作原理,我强烈建议您阅读 Oracle Java 教程。

关于java - 在 64 位机器上运行时出现 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11887957/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com