Re: [Simple-support] Ignoring unavailable annotations (JAXB onAndroid devices)
Brought to you by:
niallg
|
From: TE <al...@ho...> - 2011-09-09 18:28:00
|
Unfortunately Android does not allow external jars to implement most of the namespaces under java.* and javax.*. See http://code.google.com/p/android/issues/detail?id=13084 for details. JAXB annotations (being under java.xml) is one of them. I was hoping that it would somehow be possible to handle these in the Simple code (i.e. catch the exception and treat as if those annotations did not exist). TE _____ From: Niall Gallagher [mailto:gal...@ya...] Sent: 02 Eylül 2011 Cuma 11:07 To: sim...@li... Subject: Re: [Simple-support] Ignoring unavailable annotations (JAXB onAndroid devices) I am afraid not, Android just does not have these annotations. You could perhaps try add them to a jar and include them? But this is not something I have tried. From: TE <al...@ho...> Subject: [Simple-support] Ignoring unavailable annotations (JAXB on Android devices) To: sim...@li... Received: Thursday, 1 September, 2011, 1:13 PM Hello, >From my research, it seems that Simple is the best XML serialization/deserialization framework available for Android. The API and the framework "feels right". Thank you very much for your efforts, esp. on getting it to work on Android. :-) I have started experimenting with Simple features and one issue that I need help with is related to classes annotated both with JAXB and Simple (server side is a servlet implemented using JAX-RS via RestEasy framework, hence the use of JAXB). The following code works fine by itself (i.e. on a desktop machine, as an Eclipse Java project) but fails to run on Android: Serializer serial = new Persister(); File f = new File("somefilename.xml"); ItemCollection itemCollection = serial.read(ItemCollection.class, f); The exception stack is below. This is happening because JAXB annotations used on the ItemCollection class are not available on Android devices. Is it possible somehow to ignore these annotations while using Simple on an Android device? Does it require code change or is a workaround possible? Thanks in advance for your help. TE 08-28 13:54:15.000: ERROR/AndroidRuntime(605): java.lang.NoClassDefFoundError: javax.xml.bind.annotation.XmlAccessorType 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at java.lang.Class.getDeclaredAnnotations(Native Method) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at java.lang.Class.getAnnotations(Class.java:317) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at java.lang.Class.getAnnotation(Class.java:287) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at java.lang.Class.isAnnotationPresent(Class.java:1274) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.ClassScanner.namespace(ClassScanner.java:389) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.ClassScanner.global(ClassScanner.java:306) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.ClassScanner.scan(ClassScanner.java:287) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.ClassScanner.<init>(ClassScanner.java:114) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Scanner.<init>(Scanner.java:88) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.ScannerFactory.getInstance(ScannerFactory.java:66) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Support.getScanner(Support.java:170) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Source.getScanner(Source.java:281) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Source.getSchema(Source.java:327) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Composite.read(Composite.java:200) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Composite.read(Composite.java:150) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Traverser.read(Traverser.java:92) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Persister.read(Persister.java:632) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Persister.read(Persister.java:613) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Persister.read(Persister.java:591) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Persister.read(Persister.java:550) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Persister.read(Persister.java:528) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at org.simpleframework.xml.core.Persister.read(Persister.java:433) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at com.example.SimpleXmlTestActivity.test2(SimpleXmlTestActivity.java:52) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at com.example.SimpleXmlTestActivity.onCreate(SimpleXmlTestActivity.java:40) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.os.Looper.loop(Looper.java:130) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at android.app.ActivityThread.main(ActivityThread.java:3683) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at java.lang.reflect.Method.invoke(Method.java:507) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 08-28 13:54:15.000: ERROR/AndroidRuntime(605): at dalvik.system.NativeStart.main(Native Method) -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |