Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to call a Java extension function from Xalan on Android?

docx4j uses Xalan to convert docx to HTML, and relies heavily on Xalan Java extensions to do the work.

But Xalan extensions don't work for me on Android (working with 4.0.3). LogCat says:

05-14 15:38:02.840: I/dalvikvm(7249): DexOpt: illegal method access (call Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class; from Lorg/apache/xalan/extensions/ExtensionHandlerJavaPackage;)
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.extensions.ExtensionHandler.getClassForName, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve static method 21489: Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class;
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x71 at 0x0096
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.transformer.TransformerImpl.getDebug, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve virtual method 23717: Lorg/apache/xalan/transformer/TransformerImpl;.getDebug ()Z
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x74 at 0x0133
05-14 15:38:02.840: I/dalvikvm(7249): DexOpt: illegal method access (call Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class; from Lorg/apache/xalan/extensions/ExtensionHandlerJavaPackage;)
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.extensions.ExtensionHandler.getClassForName, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve static method 21489: Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class;
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x71 at 0x0189
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.transformer.TransformerImpl.getDebug, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve virtual method 23717: Lorg/apache/xalan/transformer/TransformerImpl;.getDebug ()Z
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x74 at 0x028e
05-14 15:38:02.840: I/dalvikvm(7249): DexOpt: illegal method access (call Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class; from Lorg/apache/xalan/extensions/ExtensionHandlerJavaPackage;)
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.extensions.ExtensionHandler.getClassForName, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.isElementAvailable
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve static method 21489: Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class;
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x71 at 0x0022
05-14 15:38:02.840: I/dalvikvm(7249): DexOpt: illegal method access (call Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class; from Lorg/apache/xalan/extensions/ExtensionHandlerJavaPackage;)
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.extensions.ExtensionHandler.getClassForName, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.isFunctionAvailable
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve static method 21489: Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class;
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x71 at 0x0021
05-14 15:38:02.840: I/dalvikvm(7249): DexOpt: illegal method access (call Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class; from Lorg/apache/xalan/extensions/ExtensionHandlerJavaPackage;)
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.extensions.ExtensionHandler.getClassForName, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.processElement
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve static method 21489: Lorg/apache/xalan/extensions/ExtensionHandler;.getClassForName (Ljava/lang/String;)Ljava/lang/Class;
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x71 at 0x004c
05-14 15:38:02.840: I/dalvikvm(7249): Could not find method org.apache.xalan.transformer.TransformerImpl.getDebug, referenced from method org.apache.xalan.extensions.ExtensionHandlerJavaPackage.processElement
05-14 15:38:02.840: W/dalvikvm(7249): VFY: unable to resolve virtual method 23717: Lorg/apache/xalan/transformer/TransformerImpl;.getDebug ()Z
05-14 15:38:02.840: D/dalvikvm(7249): VFY: replacing opcode 0x74 at 0x0091
05-14 15:38:02.860: D/AndroidRuntime(7249): Shutting down VM
05-14 15:38:02.860: W/dalvikvm(7249): threadid=1: thread exiting with uncaught exception (group=0x40a531f8)
05-14 15:38:02.860: E/AndroidRuntime(7249): FATAL EXCEPTION: main
05-14 15:38:02.860: E/AndroidRuntime(7249): java.lang.IllegalAccessError: tried to access method org.apache.xalan.extensions.ExtensionHandler.getClassForName:(Ljava/lang/String;Ljava/util/Vector;Ljava/lang/Object;Lorg/apache/xalan/extensions/ExpressionContext;)Ljava/lang/Object; from class org.apache.xalan.extensions.ExtensionHandlerJavaPackage
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:315)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:440)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:222)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:417)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:208)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xpath.XPath.execute(XPath.java:337)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:274)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:245)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:370)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:175)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2223)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2096)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1228)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:614)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1145)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1123)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.docx4j.XmlUtils.transform(XmlUtils.java:841)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.docx4j.XmlUtils.transform(XmlUtils.java:734)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at org.docx4j.convert.out.html.HtmlExporterNG2.html(HtmlExporterNG2.java:269)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at com.example.HelloAndroid.HelloAndroid.onCreate(HelloAndroid.java:58)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.Activity.performCreate(Activity.java:4465)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.os.Looper.loop(Looper.java:137)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at android.app.ActivityThread.main(ActivityThread.java:4424)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at java.lang.reflect.Method.invokeNative(Native Method)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at java.lang.reflect.Method.invoke(Method.java:511)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-14 15:38:02.860: E/AndroidRuntime(7249):  at dalvik.system.NativeStart.main(Native Method)

Any thoughts on what the problem is exactly, and workarounds?

like image 337
JasonPlutext Avatar asked May 14 '12 07:05

JasonPlutext


1 Answers

Android includes its own copy of some Apache XML libraries. If you'd like to include your own versions in your app, your best bet is to repackage it using the instructions here.

like image 151
Jesse Wilson Avatar answered Nov 06 '22 11:11

Jesse Wilson