Expand my Community achievements bar.

SOLVED

AEM Junit java.lang.NoSuchMethodError: 'boolean org.apache.commons.lang3.StringUtils.isNoneBlank(java.lang.CharSequence[])'

Avatar

Level 2

Hi All, 

 

I am getting this error for Stringutils method while debugging junit. Am i missing anything?

 

ava.lang.NoSuchMethodError: 'boolean org.apache.commons.lang3.StringUtils.isNoneBlank(java.lang.CharSequence[])'

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

As mentioned by @Imran__Khan , you might not be using the correct java api.

 

you can use the StringUtils.isNotBlank method, which is available with all the apis

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#isN...



Arun Patidar

View solution in original post

5 Replies

Avatar

Community Advisor

@archana_r This line is written as part of which file, test class or the class for which we are writing junit.

 

Here's your problem: commons-lang-2.6.jar doesn't contain the org.apache.commons.lang3 package, since that's part of version 3, and commons-lang3-3.1-sources.jar contains the source code, not the byte code.

You need to include commons-lang3-3.1.jar instead.


Refer below link for more info
https://stackoverflow.com/questions/28504174/noclassdeffounderror-org-apache-commons-lang3-stringuti...s

Avatar

Level 2

I am invoking an util class from my test class. The util class has this

StringUtils.isNoneBlank(path)method.

Is there anything, we need add in Junit test class while invkoing?

Avatar

Level 2

@Imran__Khan  Interestingly changing ito 

StringUtils.isNotEmpty(path)

 

has not thrown any error. This issue is only seen while executing junit test cases.  

Avatar

Community Advisor

StringUtils.isNotEmpty(path) will fail for null, instead use StringUtils.isNotBlank(path)



Arun Patidar

Avatar

Correct answer by
Community Advisor

As mentioned by @Imran__Khan , you might not be using the correct java api.

 

you can use the StringUtils.isNotBlank method, which is available with all the apis

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#isN...



Arun Patidar