java - Android Restlet Wrap Crashing -
i using android 1.6 , restlet android edition 2.0.7...
it crashes on wrap():
clientresource cr = new clientresource("http://myapp.appspot.com/restlet/"); irestletresource r = cr.wrap(irestletresource.class); mydata[] ss = r.getdatas();
saying that
05-10 20:40:56.272: error/androidruntime(435): java.lang.runtimeexception: unable start activity componentinfo{se.myapp.android/se.myapp.android.myappandroid}: java.lang.nosuchmethodexception ... 05-10 20:40:56.272: error/androidruntime(435): caused by: java.lang.nosuchmethodexception 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.class.getdeclaredmethods(native method) 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.classcache.getdeclaredpublicmethods(classcache.java:166) 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.classcache.getdeclaredmethods(classcache.java:179) 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.classcache.findallmethods(classcache.java:249) 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.classcache.getfulllistofmethods(classcache.java:223) 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.classcache.getallpublicmethods(classcache.java:204) 05-10 20:40:56.272: error/androidruntime(435): @ java.lang.class.getmethods(class.java:1038) 05-10 20:40:56.272: error/androidruntime(435): @ org.restlet.engine.resource.annotationutils.addannotations(annotationutils.java:131) 05-10 20:40:56.272: error/androidruntime(435): @ org.restlet.engine.resource.annotationutils.getannotations(annotationutils.java:231) 05-10 20:40:56.272: error/androidruntime(435): @ org.restlet.resource.clientresource.wrap(clientresource.java:1541) 05-10 20:40:56.272: error/androidruntime(435): @ se.myapp.android.myappandroid.oncreate(myappandroid.java:61) ...
interface looks like
public interface irestletresource { @get public mydata[] getdatas(); }
serverside restletresource looks this:
public class restletresource extends serverresource implements irestletresource { mydata[] m_datas; @override protected void doinit() throws resourceexception { m_datas = new mydata("carl",32); } @get public mydata[] getdatas() { return m_datas; //return new mydata("..",1); still crashes. } }
mydata looks this:
public class mydata implements serializable { private static final long serialversionuid = 1l; private string m_name; private int m_age; public mydata() { } public mydata(string n, int a) { m_name = n; m_age = a; } //... }
now. not crash if change resource return string instead of mydata[]. still crash if return 1 instance of mydata instead of array.
turns out need
engine.getinstance().getregisteredconverters().add(new jacksonconverter());
on client side, aswell as
getconnectorservice().getclientprotocols().add(protocol.file);
in application on srver side..
Comments
Post a Comment