NoClassDefFoundError while running on 64bit machine

早过忘川 提交于 2019-12-08 09:54:40

问题


I am getting the following exception while service startup on a 64bit Machine. But the code runs fine on a 32bit machine.

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

回答1:


Unless you (or the libraries you use) are using native code, the underlying platform is very seldom the problem in Java programs.

From the Javadoc of NoClassDefFoundError (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.

So it was present when the code was compiled, but not anymore when you try to run it elsewhere. The single-most typical reason for this is that the classpath is incorrectly set up, usually by not having the jar-file containing the class in question is not in the classpath. Revise your classpath definition and rerun.

If you are unfamiliar with how the classpath works I can strongly recommend reading up on the Oracle Java Tutorial.




回答2:


99% likelihood is that you have a CLASSPATH environment variable on the machine where it runs, and not on the machine where it doesn't. If you're starting from a service on the latter and the command-line on the former, make that 99.9%.




回答3:


Check your JAVA_HOME environment variable. If your are using eclipse IDE, check your IDE's Java Build Path.




回答4:


Same problem I'm facing. I resolved the problem by adding the following 2 jar files:

  • asm-all 2.2.3.jar
  • cglib-nodep 2.1_3.jar

and remove the asm.jar and cglib.jar from the machine (64bit) where I got error.

But my question is why this problem exits in that machine. I checked CLASSPATH, PATH and JAVA_HOME environment varibles. But all are same in the two machine.




回答5:


Same problem I'm facing. I resolved the problem by adding the following 2 jar files:

asm-all 3.3.1.jar cglib-nodep 2.1.3.jar and remove the asm.jar and cglib.jar in lib



来源:https://stackoverflow.com/questions/11887957/noclassdeffounderror-while-running-on-64bit-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!