Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting the json to bean exception

 
swapnil kachave
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following exception is occur while using the json for converting the json to bean..


Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Property 'name' has no setter method
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy._setProperty(PropertySetStrategy.java:69)
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy.setProperty(PropertySetStrategy.java:60)
at net.sf.json.JSONObject.setProperty(JSONObject.java:1547)
at net.sf.json.JSONObject.toBean(JSONObject.java:364)
at net.sf.json.JSONObject.toBean(JSONObject.java:229)
at Json.json2bean(Json.java:53)
at Json.main(Json.java:13)
Caused by: java.lang.NoSuchMethodException: Property 'name' has no setter method
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1782)
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy._setProperty(PropertySetStrategy.java:67)
... 6 more
can any one know how to resolve this..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a setter method for "name"?
 
avase kose
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Your class should be public

eg

public class xxx
{
}

not

class xxx
{
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic