Need help on NoClassDefFound error - java

I'm working on a service to prepare spreadsheet for a report. I'm using jxl-2.4.2.jar to achieve this ( please note that I can't use the latest version due to compatibility constraints). When I execute the code locally on my eclipse it works fine. My eclipse has java 1.5.
When I deploy my code in my test environment, its giving NoClassdefFound error for jxl.* ( any classes in jxl ). My test environment has IBM's java 1.5. I believe it doesn't make any difference if I use IBM's version or Sun's version of java in this context.
I believe this error could happen when JVM fails to load the class at runtime or if the class has any static methods/properties. I checked the classes and none of them have static contents. So, this could be something else.
FYI.. I'm using ant to build the project & I check the build.xml. It is showing the correct version of java 1.5. Could someone please help to fix this error? Also Just FYI.. my project resides on AIX 5.0 server.
Any help in this regard much appreciated. Thanks in advance.

This error implies that your dependency is missing at runtime i.e. the set of dependent jars is not not correct.
jxl-2.4.2.jar is not getting shipped along with deployment, so just to resolve the issue , you can manually copy this jar in dependent lib folder of deployment.
But proper fix will be to get your ANT build checked.

Related

Why is IntelliJ IDEA unable to determine java version?

I'm rather new to IntelliJ IDEA and Grails in general. I just started a new Project, selected my project JDK (11.0.1) and Gradle distribution (4.10.2). Whenever I try to run the project, I get this error:
Error initializing classpath: Could not determine java version from
'11.0.1'. java.lang.IllegalArgumentException: Could not determine java
version from '11.0.1'. at
org.gradle.api.JavaVersion.toVersion(JavaVersion.java:68) at
org.gradle.api.JavaVersion.current(JavaVersion.java:78) at
org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeException.java:29)
at
org.gradle.tooling.internal.consumer.ConnectorServices.checkJavaVersion(ConnectorServices.java:66)
at
org.gradle.tooling.internal.consumer.ConnectorServices.close(ConnectorServices.java:53)
at
org.gradle.tooling.internal.consumer.DefaultGradleConnector.close(DefaultGradleConnector.java:57)
at
org.grails.cli.gradle.cache.CachedGradleOperation.call(CachedGradleOperation.groovy:78)
at
org.grails.cli.GrailsCli.populateContextLoader(GrailsCli.groovy:525)
at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:508)
at
org.grails.cli.GrailsCli.initializeApplication(GrailsCli.groovy:306)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:269) at
org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
All other discussions of the problem I found suggested changing the Gradle distribution, which I already did. I would be so happy if anybody could help me out here.
Cheers!
May be your java configuration is not correct. If not correct follow this steps.
Goto File-> Project Structure.
Change SDK
Or gradle version is not matching jdk 11 then skip this answer.
Besides the issue with Gradle above, if you're trying to run a Grails project I don't think you can do that with JDK higher than version 8.
Even the latest Grails (3.3.8 as of this writing) is still based on SpringBoot 1.5 which does not support newer JDK, I don't know if there's a special trick to make it work.
I had to delete the .gradle directory and restart Intellij.

Code Signing of JAR dependency on JDK version

I have a requirement in my code to remove a security warning that comes for an applet code that we use in the JSP file. Understanding that code signing the JAR file for the applet will resolve the issue, we got it done and redeployed the code.
Now I see the issue fixed in some of the machines including mine (I have JDK 1.6). But others get either of the 2 error messages still (They have JDK 1.7 and 1.8)
Any advise would be greatly appreciated.
Thank you,
Sandesh

Java VM version is invalid (TestNG)

I am working on an old java project that's still using Java 1.6 . I need to write some test suites for this project and wish to use TestNG for this purpose. However, on running the test I continuously get the error
VM version 1.6.0 is invalid, Java 1.7 or above is required for running TestNG.
I checked out the other similar questions but none of them answer my query. Downloading an old version of TestNG also doesn't work (I tried several 6.8.22 versions). I am using a mac.
Can someone please help me with this? Is it possible for me to define a different execution environment for testNG only? (so that the rest of the project runs Java 1.6 but testNG takes 1.8)
Any kind of help will be great. Thanks

"The type java.util.Map$Entry cannot be resolved" (tomcat6 + JDK7)

I've a JSP app which gives me the error:
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
Stackoverflow is full of post about this error, but all of them get to solve just compiling the .java files using JDK7, plus using tomcat with same version (I mean, below to JDK8 which seems to be the problem, because some IDE version and tomcat versions doesn't support it).
The problem is that I've built my app (.java files) using JDK 1.7.0_79, plus I've my tomcat 6 server using the same one.
So there's no JDK 8 anywhere... Some screenshots with data:
My JVM directory:
Error stacktrace:
Tomcat process (running using JDK7):
Javac version used to compile:
Any idea about why do I still get this error?
Thank you in advance
Run Tomcat with Java 6 or upgrade to Tomcat 7 and make sure you don't have some old pre-Java 5/pre-generics library on the classpath.
Why do you get this error? Somewhere in the JSP code (not your code, mind), is a dependency on java.util.Map.Entry. This could be in code which Jasper generates from your JSP.
It's not a direct dependency; rather your code (or the Java code generated from your JSP) needs something else which then needs java.util.Map.Entry
But the interface has changed in some way. Usually, that's with Java 8 because of the new static helper methods which they added: The name of the class is the same (which makes the error so confusing) but the API has changed and the code can't find something (or found something it didn't expect).
A similar problem can happen when you try to compile against a pre-generics class (even though that should work).
Even worse, import java.util.Map in your JSP works. It's the existing bytecode somewhere else that causes the trouble.
[EDIT]
In my /WEB-INF/lib/ folder I've: commons-fileupload, commons-io, poi and rt (may this one be the problem?)
Yes :-) rt.jar is the Java runtime. It contains java.* and in your case, a version of java.util.Map which doesn't match the one from your Java VM.
Remote it and it should work.
I had the same problem with Eclipse Mars, JDK 8 and the Tomcat Maven Plugin. It was solved changing the plugin version to 2.2 in my pom.xml.
I have tomcat-7.0.22 and jdk1.8.0_45 and I replaced the ecj-3.7.jar file that is in tomcat/lib directory with ecj-4.6.1.jar file that's included in the tomcat-8.0.43 and that got rid of the error.
for more information take a look at this post How to change tomcat compiler

bad version in class file

When I use certain jars in one of the connector projects i write for lombardi in TeamWorks eclipse i get a bad class version exception...
any ideas how this might be resolved..
Regards,
Adhir
You will get this error if you are using (say) Java 1.5 and you are using a JAR compiled with Java 1.6.
The easiest way to resolve is to upgrade your version of Java to the one used by the JAR.
Try to compile/recompile all your stuff with the same compiler.
Typically this happens when you have something compiled with a higher version and
you try to run it with an older one.
This problem can also be caused by an expired (365-day) Android certificate referenced by Eclipse.
See "Debug certificate expired" error in Eclipse Android plugins for details.
This is a result of running code compiled with a compiler version that is greater than the version of java you are using to run it. IE Code compiled with 1.6 and you are running it with 1.5. See this post to determine what version it was compiled with.
how-can-i-find-the-target-java-version-for-a-compiled-class
the easiest fix is to run it with the most recent JVM.
Root Cause for this error is that: jars including in your project is complied from other version of java and you are compiling your project from other version of java simply upgrading version of java will resolve this problem.
I also faced the same problem.

Categories