Repackaged JAXB on Android ends in Runtime Exception

I am developing an Android app which needs to render components dynamically according to an XML string. This XML string is based on an XSD and I am directly getting the XML from a server. I have used JAXB xjc to create an object model from the XSD. But now I want to be able to unmarshall and parse the complete XML with JAXB.I went through a few posts here and in this post, I found a solution where the last solution gives a solution to use a repackaged jaxb library. I followed the following steps:- 1.Import the librarys:activation.jaradditionnal.jarae-jaxb-2.2.5.jaristack-commons-runtime.jarjaxp-datatype.jartxw2-20110809.jar[*]Replace my jaxb imports to ae.jaxb.[*]Added \[code\]RuntimeInlineAnnotationReader.cachePackageAnnotation(RenderXml.class.getPackage(), new XmlSchemaMine(""));\[/code\]to the onCreate method in my code. Here RenderXml is the name of my Activity.I am still getting the following runtime errors :-\[code\]12-04 13:44:39.820: E/AndroidRuntime(2219): FATAL EXCEPTION: main12-04 13:44:39.820: E/AndroidRuntime(2219): java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlRegistry12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.Class.getDeclaredAnnotation(Native Method)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.Class.getAnnotation(Class.java:260)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getClassAnnotation(RuntimeInlineAnnotationReader.java:109)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getClassAnnotation(RuntimeInlineAnnotationReader.java:59)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:330)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:461)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:299)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1164)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:146)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:237)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.reflect.Method.invokeNative(Native Method)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.reflect.Method.invoke(Method.java:511)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:186)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.javax.xml.bind.ContextFinder.find(ContextFinder.java:361)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)12-04 13:44:39.820: E/AndroidRuntime(2219): at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:313)12-04 13:44:39.820: E/AndroidRuntime(2219): at com.example.testuirenderxml.RenderXml.generateFirstMenu(RenderXml.java:79)12-04 13:44:39.820: E/AndroidRuntime(2219): at com.example.testuirenderxml.RenderXml.onCreate(RenderXml.java:112)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.Activity.performCreate(Activity.java:5104)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.ActivityThread.access$600(ActivityThread.java:141)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.os.Handler.dispatchMessage(Handler.java:99)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.os.Looper.loop(Looper.java:137)12-04 13:44:39.820: E/AndroidRuntime(2219): at android.app.ActivityThread.main(ActivityThread.java:5039)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.reflect.Method.invokeNative(Native Method)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.reflect.Method.invoke(Method.java:511)12-04 13:44:39.820: E/AndroidRuntime(2219): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)12-04 13:44:39.820: E/AndroidRuntime(2219): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)12-04 13:44:39.820: E/AndroidRuntime(2219): at dalvik.system.NativeStart.main(Native Method)12-04 13:44:39.820: E/AndroidRuntime(2219): Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.bind.annotation.XmlRegistry" on path: /data/app/com.example.testuirenderxml-2.apk12-04 13:44:39.820: E/AndroidRuntime(2219): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)12-04 13:44:39.820: E/AndroidRuntime(2219): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)12-04 13:44:39.820: E/AndroidRuntime(2219): ... 35 more\[/code\]I have the need to use jaxb because I have to generate the object model from an xsd which is updated regularly, is there any other way to create the object model and then parse the xml with the help of this object model so as to achieve what I want to?
 
Back
Top