Five Stars

ClassNotFoundException: java.lang.NoClassDefFoundError

Hi there;

In one of my tJavaRow I’m using the library “org.apache.commons.lang3” where I use the Static class StringUtils and the method isBlank().

Obviously I added the java import org.apache.commons.lang3.StringUtils; on the advance tab of the tJavaRow.

 

The code compiles properly!

But at run time I get:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

 

So it compiles! therefore the compiler found the library!!!

But not the run time???

 

The library is physically in the following path under the Talend install:

 

lang3 in plugins.PNG

 

 

 

 

Talend knows that it is there as shown here:

talend know lang3.PNG

 

 

 

 

 

 

So what is out of synch that the compiler finds it but not the run time and how do I fix it.?

Do I add reference in one of the POMs?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Five Stars

Re: ClassNotFoundException: java.lang.NoClassDefFoundError

Ok Since I'm back around I'll note my findings so others can benefit.

 

The issue is that talend was installed with Admin privileges and now when I run it without admin right I get the error above. If I run it with admin rights (run as administrator) it works fine!

 

Not intuitively obvious!!

 

4 REPLIES
Moderator

Re: ClassNotFoundException: java.lang.NoClassDefFoundError

Hello,

Do you want to install external jar file into studio?

There are two ways for you to import and use an external jar.
1)Using tLibraryload component to load the jar file at the begininig of job. for example:
tLibraryLoad
   |
tJava(on tJava, use the external API)

2)Creating custom routine, import the external jar file by clicking on the routine name and editing the routine libraries, and then call this routine in the job.

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.
Five Stars

Re: ClassNotFoundException: java.lang.NoClassDefFoundError

Hi there;

 

Maybe I do not understand the meaning of what I am seeing.

Given both images in my initial posting specially in the second which is specifically related to "installation details"

I would have expected that the package was there and visible. Specifically that given the import statement the code compiles.

 

Anyhow at this point it is mystery as I think some configuration is out of synch but the tLoadLibrary did work.

Five Stars

Re: ClassNotFoundException: java.lang.NoClassDefFoundError

Ok Since I'm back around I'll note my findings so others can benefit.

 

The issue is that talend was installed with Admin privileges and now when I run it without admin right I get the error above. If I run it with admin rights (run as administrator) it works fine!

 

Not intuitively obvious!!

 

Moderator

Re: ClassNotFoundException: java.lang.NoClassDefFoundError

Hello,

Thanks for sharing your solution with us.

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.