0

I am getting noclassdeffounderror after deploying the jar with changes to a certain class file. I am able to see the class file in the jar when i extracted the jar file through the 7zip.

I also de-compiled the .class file to find any errors but did not get any thing .

While deploying i Just dragged the .class file from the eclipse work space into a pre existing jar file. does that matter?

Does the jdk version in which the jar file is compiled matter because i am running on jre 1.7 in eclipse but my deployment environment is of jre 1.6 ?

Pratik Kar
  • 31
  • 10

4 Answers4

1

The problem in my mind is that the class added to the jar has been compiled under a different version of Java. I would guess that you've compiled at 1.7 and 12c is running 1.7, whereas 11g is running 1.6. Either compile the class in 1.6 and add it to the jar or recompile the jar in 1.7 and ensure the environment you're running on has 1.7 or above.

Robert Bain
  • 9,113
  • 8
  • 44
  • 63
  • But I deployed the same jar on one server with weblogic 12c configuration it worked properly. but i got this when deployed it with weblogic 11g. – Pratik Kar Jan 14 '15 at 21:48
  • Are both servers running the same version of java? – Robert Bain Jan 14 '15 at 23:09
  • Yes, You analysed it correctly jdk 1.7 + weblogic 12c = perfectly working jdk 1.6 + weblogic 11g = Exceptions java.lang.NoClassDefFoundError: com/dell/gmfs/framework/jms/QUtil 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 weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:328) – Pratik Kar Jan 15 '15 at 09:33
0

A NoClassDefFoundError states that the class was not available during runtime. Make sure you have it in class path or the static initializer (if present) is not breaking. For the later, you will see an ExceptionInInitializerError somewhere below in the stacktrace.

Not too sure about if jdk version matters or not.

amigo21
  • 381
  • 1
  • 4
  • 18
0

I am getting noclassdeffounderror after deploying the jar with changes to a certain class file.

This is caused when there is a class file that your code depends on, and it is present at compile time but not found at runtime (see this answer).

While deploying i Just dragged the .class file from the eclipse work space into a pre existing jar file. does that matter?

Yes, it matters. Be sure to put the class file back in the correct package folder. For example, a class in package com.foo must be in the folder com/foo inside the jar file. It's possible your altered version landed somewhere else when you dragged it into the jar file.

Does the jdk version in which the jar file is compiled matter because i am running on jre 1.7 in eclipse but my deployment environment is of jre 1.6 ?

The jar file itself is just a zip file, so no, it doesn't matter which version of Java you were using to compress the contents of the jar file.

However, if you've re-compiled a single class from an existing jar file, it does matter which version of Java was used to compile the other classes in the jar file, because you could cause the class to be incompatible with its companion classes.

Community
  • 1
  • 1
gknicker
  • 5,509
  • 2
  • 25
  • 41
  • But I deployed the same jar on one server with weblogic 12c configuration it worked properly. but i got this when deployed it with weblogic 11g. And as far the package is concerned it is in the same way as described by you. And the last point Yes I have recompiled only that class with the accurate class path as that of the deployment environment. – Pratik Kar Jan 14 '15 at 22:05
  • 1
    Try compiling that one class with JDK6 – gknicker Jan 14 '15 at 22:24
-2

This worked perfectly when i compiled the code in jdk 1.6 . java.security.SecureClassLoader is changed in both the versions. thats why i suppose i got the error .

Pratik Kar
  • 31
  • 10