Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isBlank(Ljava/lang/String;)Z Error

Tags:

java

json

I have created WS02MB project. Inside that project I have used net.sf.json.JSONObject, accumulate method above error occur. Please advise how to resolve this issue.

Sample code:-

JSONObject json = new JSONObject();
String pair= "{long sting here}";//11586 letter count
json.accumulate("message", pair); 

I have used following jar file:-

andes-client-3.1.1.jar
commons-beanutils.jar
commons-collections-3.2.1.jar
commons-lang.jar
commons-lang3-3.5.jar
commons-logging-1.2.jar
ezmorph-1.0.6.jar
geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
json-lib-2.4-jdk15.jar
log4j-1.2.13.jar
org-apache-commons-codec.jar
org-apache-commons-logging.jar
org.eclipse.paho.client.mqttv3-1.0.2.jar
org.wso2.carbon.logging-4.4.1.jar
org.wso2.securevault-1.0.0-wso2v2.jar

Error Message:-

java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isBlank(Ljava/lang/String;)Z
at org.apache.commons.lang.math.NumberUtils.createNumber(NumberUtils.java:500)
at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:417)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:1008)
at net.sf.json.JSONObject._fromString(JSONObject.java:1201)
at net.sf.json.JSONObject.fromObject(JSONObject.java:165)
at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:139)
at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:103)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:262)
at net.sf.json.JSONObject._processValue(JSONObject.java:2655)
at net.sf.json.JSONObject.processValue(JSONObject.java:2721)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2736)
at net.sf.json.JSONObject._accumulate(JSONObject.java:2635)
at net.sf.json.JSONObject.accumulate(JSONObject.java:1543)
like image 271
Thusitha Indunil Avatar asked Jan 05 '17 12:01

Thusitha Indunil


2 Answers

Finally I found the issue, This is due to commons-lang.jar and commons-lang3-3.5.jar conflict. So I have removed commons-lang.jar from Gradle task. Now it is working without any issue.

like image 80
Thusitha Indunil Avatar answered Nov 11 '22 10:11

Thusitha Indunil


I got the same error with a Maven build. I accidentally imported commons.lang utility, when I should have imported commons.lang3. I would have thought this would be caught in the compile/build phase and not as a runtime exception.

like image 45
DaithiG Avatar answered Nov 11 '22 11:11

DaithiG