Reputation: 832
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)
Upvotes: 11
Views: 43208
Reputation: 426
None of these other solutions solved my issue. My issue was that another commons-lang dependency (a lower version) was being pulled in by another dependency. If you open the dependency hierarchy in eclipse and search for org.apache.commons.lang you should be able to find the dependency that is pulling it in. Add an exclusion under that dependency in the pom as follows:
<dependency>
<groupId>Problem dependency group</groupId>
<artifactId>Problem dependency</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>org.apache.commons.lang</artifactId>
</exclusion>
</exclusions>
</dependency>
This should stop the problem dependency from pulling in the other version of commons-lang and should fix the noSuchMethodError.
Upvotes: 0
Reputation: 969
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.
Upvotes: 2
Reputation: 832
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.
Upvotes: 26