Four Stars

[resolved] Another java.lang.NoClassDefFoundError post

I imported an old job into a new job (its basically a template for the new job) and I worked on it a bit. I tried running it but now I am getting this error:
Exception in thread "main" java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.NoClassDefFoundError: org/apache/commons/lang/time/DateFormatUtils
If I open the old job (template) and run it, I do not get this error.
I went through all the old posts and can tell you that
a) My environment has no spaces or slashes: /home/jkrfs/TOS-All-r63143-V4.2.2
b) I exported the job, deleted the project, created a new project and imported it again
c) ClassPath in environment is correct, this error does not come up in any other projects/jobs that uses the same package.
d) Started talend with the -clean parameter
Any help would be greatly appreciated!
Using Talend 4.2.2 release
1 ACCEPTED SOLUTION

Accepted Solutions
Four Stars

Re: [resolved] Another java.lang.NoClassDefFoundError post

Resolved this by using tLibraryLoad to manually load the apache commons library.
Why is it that I don't always need to do this?
7 REPLIES
Community Manager

Re: [resolved] Another java.lang.NoClassDefFoundError post

Hi
Which is the old version? Do you have the same problem on other job? Can you see the jar commons-lang-2.4.jar in the folder <TOS studio installation>/lib/java after you import the job?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: [resolved] Another java.lang.NoClassDefFoundError post

When I say old version I don't mean an old Talend version, I meant a previous version of my job.
To be more clear, the two jobs are essentially the same there are only a few minor differences. The first job is not much different then the second job, and both jobs uses the Apache Commons library. The only difference is that the first job still runs without a problem, but I get the NoClassDefFound error on the second one.
commons-land-2.4.jar is present in the lib/java folder.
Four Stars

Re: [resolved] Another java.lang.NoClassDefFoundError post

I did notice something, in my workspace/.Java/.classpath file I have
<classpathentry kind="lib" path="/home/jkrfs/TOS-All-r63143-V4.2.2/lib/java/commons-lang-2.6.jar"/>
but no reference to 2.4. In my lib/java/ directory, I have both 2.4 and 2.6 in there.
Not sure if this would matter, because I have another project in the same workspace that uses the same DateFormatUtils method and it runs perfectly fine.
Four Stars

Re: [resolved] Another java.lang.NoClassDefFoundError post

So this is weird. I decided to extend my flow to another component and the error went away.
The tJava component that uses the apache commons class is out of the picture, but here is the difference between the job working and not working.
You can see the error in the first screenshot, the second screenshot I got another error thats unrelated to the NoClassDefFoundError exception. So technically, it is now working correctly.
Four Stars

Re: [resolved] Another java.lang.NoClassDefFoundError post

I am having this issue again, I put a screenshot below. I know the class I am trying to use is there ( I have used it in other Talend jobs)...not sure why I am getting this error...
Four Stars

Re: [resolved] Another java.lang.NoClassDefFoundError post

Resolved this by using tLibraryLoad to manually load the apache commons library.
Why is it that I don't always need to do this?
One Star

Re: [resolved] Another java.lang.NoClassDefFoundError post

Hi JKFRS,
             Thanks for your insight. I was able to make Talend build the class once  i renamed the workspace path which had space in its name.
Thank You