2012-05-14 9 views
6

docx4j usa Xalan para convertir docx a HTML, y depende en gran medida de las extensiones Xalan Java para hacer el trabajo.¿Es posible llamar a una función de extensión de Java desde Xalan en Android?

Pero las extensiones Xalan no funcionan para mí en Android (trabajando con 4.0.3). LogCat dice:

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) 

¿Alguna idea de lo que es exactamente el problema y las soluciones?

+0

¿Cómo declara y usa su función de extensión? –

+0

Con xmlns: java = "http://xml.apache.org/xalan/java", algo así como llamando pública estática DocumentFragment myStaticMethod ( \t \t cadena s, \t \t NodeIterator b) – JasonPlutext

+0

tengo XSLT (no en Android) utilizando "Java: org.foo.Bar()" - de estilo y funciones que utilizo 'xmlns: java = "http://xml.apache.org/xalan/java" '. Después de publicar este comentario, puedo ver que el 'http: //' está oculto de tu comentario original ... puedes estar peleando contra un SecurityManager u otra cosa. * shrug * –

Respuesta

3

Android incluye su propia copia de algunas bibliotecas Apache XML. Si desea incluir sus propias versiones en su aplicación, la mejor opción es volver a empaquetarla usando el instructions here.

+0

He reempaquetado varias cosas (por ejemplo, javax.xml.bind), pero no hay ninguna sugerencia de que ese sea el problema aquí, ¿verdad? – JasonPlutext

Cuestiones relacionadas