One Star

Exception in thread "main" java.lang.NoClassDefFoundError

Hi all,
I had a totally running enviroment with Talend for Big Data on Ubuntu Linux (12.04 LTS).
We have changed the Java version from 1.6 to 1.7 with command: sudo update-alternatives --config java and then switched back to Java 1.6
Now all Talend jobs don't work.
The error is (in this example for the job "User" in the project BD):

Exception in thread "main" java.lang.NoClassDefFoundError: bd/user_0_1/User
Caused by: java.lang.ClassNotFoundException: bd.user_0_1.User
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: bd.user_0_1.User. Program will exit.

I think this happen because the variables JAVA_HOME and CLASSPATH does not have a value.
Anyone know how to set this variables ?
We are using Talend for Big Data version 5.5.1.r118616
java -version return: 
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-1ubuntu0.12.04)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
Thanks in advance
11 REPLIES
Seventeen Stars

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Your post is a bit confusing:
At first you sad you have changed the Java version and have also changed the alternatives but actually this should cause using Java 7 as default. But your check of the java version still shows Java 6.
What do you mean with running the job: do you mean in the studio or do you mean the already exported jobs (e.g. running per cron) does not work anymore?
If it is the studio:
Please open the preferences and here Java-Installed JREs and take care you have Java 7 here in the list.
Next setup the variables:
Here an example for an Mac but it works in the same way under Linux.
One Star

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Your post is a bit confusing:
At first you sad you have changed the Java version and have also changed the alternatives but actually this should cause using Java 7 as default. But your check of the java version still shows Java 6.
What do you mean with running the job: do you mean in the studio or do you mean the already exported jobs (e.g. running per cron) does not work anymore?
If it is the studio:
Please open the preferences and here Java-Installed JREs and take care you have Java 7 here in the list.
Next setup the variables:

Here an example for an Mac but it works in the same way under Linux.

Thank you for the reply.To clarify a bit: we switched to Java 7 with update alternatives (Java 7 is already installed) and then we switched back to Java 6 (always with update alternatives).Before this process all is working, after the two switch we have the error. Soon i w ill try your solution and let you know.
One Star

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Your post is a bit confusing:
At first you sad you have changed the Java version and have also changed the alternatives but actually this should cause using Java 7 as default. But your check of the java version still shows Java 6.
What do you mean with running the job: do you mean in the studio or do you mean the already exported jobs (e.g. running per cron) does not work anymore?
If it is the studio:
Please open the preferences and here Java-Installed JREs and take care you have Java 7 here in the list.
Next setup the variables:

Here an example for an Mac but it works in the same way under Linux.

We have tried with your solution, but there is not any entry "Java-Installed JRE".
Under Java there is only two entries that, translated in english, are:

user libraries (that is empty)
path variables (contains a lot of absolute path with jar classes)

I forgot to mention that we run the job from inside the studio
Moderator

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Hi badlinhat,
So far, talend don't support for Open JDK. Have you tried Oracle JDK to see if everything is OK with you?
Have you already checked document about:TalendHelpCenter:Compatible Platforms?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seventeen Stars

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Hi Sabrina, this is a typical support answer what actually does not help. This issue is well known and has nothing to do with OpenJDK or Oracle JDK. It is an issue which is caused by a confusion of the studio about the Java releases. I have not figured out what exactly happens but it occurs also on a Mac if you switch the Java version and on a Mac there is usually non OpenJDK running.
I have to setup the JREs and next the libraries ALWAYS when I change anything in the Java release (e.g. an update from Oracle).
For me it looks like a bug.
Moderator

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Hi jlolling,
Thanks for your quick response and explanation.
We will make an investigation on it to see if it is a bug.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Hi badlinhat,
So far, talend don't support for Open JDK. Have you tried Oracle JDK to see if everything is OK with you?
Have you already checked document about:TalendHelpCenter:Compatible+Platforms?
Best regards
Sabrina

Hi Sabrina,
thank you for your reply.
We have switched to Oracle Java 1.6, this is the output of "java -version":
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
But the error remain the same....
Anyone know how to set JAVA_HOME and CLASSPATH ?
Seventeen Stars

Re: Exception in thread "main" java.lang.NoClassDefFoundError

OK again, check if it looks like in your studio (it does not matter which OS, the path to the java jdk is for sure different on your machine).


and than this:

the weird problem is the list of jres will be filled right after you have clicked on the node (Execution Environment) -> this is also a bug.
If both are empty, add in this dialog the current java runtime.
The studio does not use the JAVA_HOME env var and the CLASSPATH variable for the studio cannot manipulated from outside. The studio also does not read this var from the system. Actually the CLASSPATH var should never be set in the system because it depends on the application.
One Star

Re: Exception in thread "main" java.lang.NoClassDefFoundError

OK again, check if it looks like in your studio (it does not matter which OS, the path to the java jdk is for sure different on your machine).


and than this:

the weird problem is the list of jres will be filled right after you have clicked on the node (Execution Environment) -> this is also a bug.
If both are empty, add in this dialog the current java runtime.
The studio does not use the JAVA_HOME env var and the CLASSPATH variable for the studio cannot manipulated from outside. The studio also does not read this var from the system. Actually the CLASSPATH var should never be set in the system because it depends on the application.

Thanks jlolling,

But as i write on a previous post (see screenshoot attached) we don't have an option like this...
I cannot choose JRE versione inside Talend even if I run Talend as a super user.
I find an ".ini" file that contains the parameter for the JVM, but i don't know how modify it...
Seventeen Stars

Re: Exception in thread "main" java.lang.NoClassDefFoundError

OK I am running out of ideas. I have never seen a studio which does lacks these fundamental settings.
Perhaps it helps if you give the studio an explicit -vm parameter pointing to the java home in the ini file.
Moderator

Re: Exception in thread "main" java.lang.NoClassDefFoundError

Hi badlinhat,
Is there any update for your issue?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.