NoClassDefFoundError while running on 64bit machine - java

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

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.

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%.

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

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.

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

Related

Java: Including jar in classpath

I created a Java project in Eclipse and created a simple class with a main method.
Problem: when I run the program(without any server etc), I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
at autoPEC.main(autoPEC.java:6)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more
What I tried to solve the problem: included path to commons-codec.jar in the environment variables JAVA_HOME by putting a semicolon after the jdk path
Result: class still does not run
I think that the problem could be that I am not correctly including the classpath. How should I do this?
Google the missing jar and include it in the Java Build path
Reason for this exception is missing of a jar.
please add the jar(Commons-codec.jar) file needed for this org.apache.commons.codec.DecoderException
Download it from here
http://commons.apache.org/proper/commons-codec/download_codec.cgi
then put it in your classpath

Cannot inherit from final class error

What does this error mean .. It runs fine in Eclipse but not in intellij idea
Exception in thread "main" java.lang.VerifyError: Cannot inherit from final class
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 com.couchbase.client.ViewConnection.createConnections(ViewConnection.java:120)
at com.couchbase.client.ViewConnection.<init>(ViewConnection.java:100)
at com.couchbase.client.CouchbaseConnectionFactory.createViewConnection(CouchbaseConnectionFactory.java:179)
at com.couchbase.client.CouchbaseClient.<init>(CouchbaseClient.java:243)
at com.couchbase.client.CouchbaseClient.<init>(CouchbaseClient.java:175)
at com.couchbase.App.putincbase(App.java:122)
at examplesCons.TestCons.run(TestCons.java:89)
at examplesCons.TestCons.main(TestCons.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
I get this error when I try to run couchbase using couchbase-client-1.1.6.jar from Intellij IDea.
if you're using kotlin, add open to your class (extends RealmObject) declaration
open class Foo() {
}
The message means what it says.
Somewhere, somehow you have managed to create a class that extends a superclass, where the superclass has been declared as final.
The most likely cause is that you have a conflict between your build classpath and your launch classpath. In other words, you are compiling your subclass against a version of the superclass that is not final, and then running against a version that is final. The verifier is saying (correctly) that this is wrong.
If it is not your build / one of your classes that is causing this, then it is some internal conflict within the CouchDB client classes that you are using. Indeed the fact that this is a VerifyError rather than an IncompatibleClassChangeError suggests that this maybe a problem with some dynamically generated bytecodes.
I also faced this with IntelliJ Idea: 2018.3 Community Edition, However running following fixed it for me:
mvn -U idea:idea clean compile install -DskipTests
maybe you would be extend a java class which is marked as final keyword but as you know, inheritance is not possible with final class.

Errors with Java Applet on web

A java applet that I wrote works exactly as intended when I run it from the code in the applet viewer on my computer. However, when I uploaded it to my website, I get a series of errors. I looked up the errors but can't find any useful information to help figure out the problem. Here are the errors.
java.lang.NoClassDefFoundError: Main
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 sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:678)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: Main
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 13 more
Exception: java.lang.NoClassDefFoundError: Main
I understand that this might not be descriptive enough without a sample of my code but can anyone discern anything from these errors? Thanks
It simply means the class Main referenced in your code is not included in the applet.
Most likely you did not included the class when exporting to jar.
It'd be great if you included your code, but the problem is likely that you're referencing a class called Main, yet none exists in the CLASSPATH of the service dumping this exception.
You likely need to either create (or rename!) the source to "Main.java" and build a Main.class and put it in the correct path or alter the path to reference where Main.class (or the archive containing Main.class) is stored.

Rubymine startup error java.lang.NoClassDefFoundError: com/intellij/util/lang/UrlClassLoader

I am using Ubuntu 11.04, when i start RubyMine3.1 it gave this error.
Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/util/lang/UrlClassLoader
at com.intellij.idea.Main.main(Main.java:55)
Caused by: java.lang.ClassNotFoundException: com.intellij.util.lang.UrlClassLoader
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 1 more
I tried every thing, i also have sun-java installed, set it default by update-java-alternatives, also my JAVA_HOME, JDK_HOME, RUBYMINE_JDK points to the sun-java directory, but still no success.
Does any one have any idea about it?
Damaged download or some classes left from older version? Try to download again and unpack into an empty directory.
Did you install any third-party plug-ins? In this case you should try to delete them from the plugins directory.
The class which fails to load is located in RubyMine/lib/util.jar. Maybe you are using an old version of rubymine.sh which doesn't add util.jar to the classpath?

running scala apps with java -jar

I got some problems with the java. Check it out.
sebastian#sebastian-desktop:~/scaaaaaaaaala$ java -cp /home/sebastian/.m2/repository/org/scala-lang/scala-library/2.8.0.RC3/scala-library-2.8.0.RC3.jar:target/scaaaaaaaaala-1.0.jar scaaalaaa.App
Hello World!
That's cool, right, but how bout this:
sebastian#sebastian-desktop:~/scaaaaaaaaala$ java -cp /home/sebastian/.m2/repository/org/scala-lang/scala-library/2.8.0.RC3/scala-library-2.8.0.RC3.jar -jar target/scaaaaaaaaala-1.0.jar
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Application
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at scaaalaaa.App.main(App.scala)
Caused by: java.lang.ClassNotFoundException: scala.Application
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 13 more
Wat the heck? Any idea why the first works and not the 2nd? How do I -jar my scala??
My thanks in advance, brother.
If you define -jar the -classpath is ignored:
Java manual:
-jar When you use this option, the JAR file is the source of all user
classes, and other user class path
settings are ignored.
You can define the classpath dependencies in the Manifest metadata.
The easiest way to start your app is using the scala scripts:
scala -classpath target/scaaaaaaaaala-1.0.jar scaaalaaa.App Hello World!
Simply running
scala scaaaaaaaaala-1.0.jar
works for me with 2.11.6
use sbt-assembly sbt plugin to produce a jar containing all dependencies
sbt-assembly github
e.g. add a line in project/plugins.sbt:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
adjust your build.sbt e.g. with
mainClass in (assembly) := Some("mypackage.mysubpackage.MyMainClass")
assemblyJarName in assembly := "my_assembly.jar"
then build your assembled jar with
sbt assembly
and launch it with
java -jar ./target/scala-2.12/my_assembly.jar
Et voilĂ , no class-path this & thats needed any more. only 1 jar.
For an executable jar, the classpath should be in the jar's manifest. For help on doing that, look through the answers to Stackoverflow: How to create an executable jar with dependancy jars.
Below is the way to execute the Scala Executable Jar
We need scala installed in your system.
Here first will give the jar path and jar name
If your code needs any dependency jar then keep all jar in one directory and give a path of this in command like below after the ":".
At last give your class/object name.
scala -cp "/your/jar/path/jar_name.jar:/your/dependency/jar/path/*"
SampleCode

Categories