java - LazyList.decorate - InstantiateFactory: The constructor must exist and be public exception -


i have code:

public class user    ... private list<country> countries = lazylist.decorate(new arraylist(), factoryutils.instantiatefactory(country.class));     private string country;  ... public void setcountries(list<country> countries) {         this.countries = countries;     }      public list<country> getcountries() {         return countries;     } ... 

in country class:

public class country {      private int countryid;     private string countryname;      public country(int countryid, string countryname)     {         this.countryid = countryid;         this.countryname = countryname;     }      public int getcountryid() {         return countryid;     }      public void setcountryid(int countryid) {         this.countryid = countryid;     }      public string getcountryname() {         return countryname;     }      public void setcountryname(string countryname) {         this.countryname = countryname;     }  } 

when create new user object give exception:

java.lang.illegalargumentexception: instantiatefactory: constructor must exist , public

anyone know why?

seems constructor have is:

public country(int countryid, string countryname) 

while factory expects find no-arg constructor (common requirement):

public country() 

add country class , you'll fine.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -