简体   繁体   中英

why am i getting the noclassdeffounderror after deploying?

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 ?

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.

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM