UnsupportedClassVersionError: Bad version number but JRE correct versi
We use JVM version 1.5 on our Sun Unix deployment server. The TIS client is set up to use JVM 1.5 (See images). The path to the JRE is the first in the PATH env var.
I have used Javap to determine the JRE version of a built job and that returns
minor version: 0
major version: 49
Which corresponds to version 1.5.
But when a job is built, deployed and run or distant run the following error occurs.
Exception in thread "main" java.lang.Error: java.lang.Error: java.lang.UnsupportedClassVersionError: Bad version number in .class file
We have a number of developers using TIS 4.2 and some have the problem and some don't even though the same settings are used by all.
Does anyone know what the problem could be and a solution?
Many thanks in advance Dave
Hi
The Java versions of local environment and remote environment(Server) should be the same.
Or you might encounter UnsupportedClassVersionError issue.
Regards,
Pedro
Hi Pedro We are using JRE 1.5 on both the Sun server and on the PC that runs the client and performs the build. There are other JRE's and JDK's on the PC as they are needed to run other software. The odd thing is that looking at a class file from the build that errors, reports that it was built to jre 1.5? It looks like there is some other environment issue occurring. How does the client and the command line choose a JRE on windows (XP)? Cheers Dave
Hi Pedro
Running both commands returns the following
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode)
javac java version "1.6.0_17"
Which is correct as we need a 1.6 JRE for other software. What we need to do is force Talend to use a 1.5 JRE on a PC that also has 1.6 jre installed. I thought this was acheived by the settings in the preferences as per the images?
Many thanks Dave
Hi Dave You see. This is the root reason. On your PC, JDK 1.6 compiles the talend job while on server it is executed by JRE 1.5. Then UnsupportedClassVersionError orrcurs. Change Java environment variables into 1.5. Regards, Pedro
Thanks Pedro How do we do this without causing issues with other systems requiring the 1.6 version? Does Talend use the registry entry to locate the JRE or the PATH or JAVA_HOME? Many thanks Dave
We have investigated this issue further with the following findings. We have built the same job with one PC that can build successfully and one that does not. Comparing the zip files the one that works has a ojdbc5-11g.jar in the lib directory and the one that does not work has ojdbc6-11g.jar file (see image). If I check the major and minor versions of a class file within the jar the following is revealed. Working build minor version: 0 major version: 49 i.e. version 1.5 Non working build minor version: 0 major version: 50 i.e. version 1.6 It looks like for a non working build the majority of the class files are built to 1.5 but a 1.6 built jar file has been included. What do we need to set PATH, JAVA_HOME, CLASSPATH etc to ensure that when we build a job it will use the correct version of all the dependencies? Many thanks in advance Dave
Hi Pedro
I have managed to get my client to distant run without the Bad Version error. I changed the JAVA_HOME and PATH environment variables to point to a 1.5 JDK but this had no effect. As I get version 1.6 when I type java -version I then removed my Java 6 installation. This allowed me to distant run without error. So it looks like Talend is using the Registry registered Java runtime.
The problem is that I need the Java 6 environment for other software. Is there a way of forcing Talend to use a non Registry registered version of Java?
Many thanks Dave