B4J Question Write in Microsoft Word ... doesn't work! ... why?

JOTHA

Well-Known Member
Licensed User
Longtime User
Hi forum,

I've tried to start the solution from Erel https://www.b4x.com/android/forum/threads/write-in-microsoft-word.59328/#post-373767 but it doesn't work.

Logfile:
main._savedocument (java line: 133)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main._savedocument(main.java:133)
at b4j.example.main._appstart(main.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
Caused by: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
at org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43)
at org.apache.poi.xwpf.usermodel.XWPFDocument.commit(XWPFDocument.java:811)
at org.apache.poi.ooxml.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:462)
at org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:236)
... 14 more
The error apears at "SaveDocument".
It generates a DOCX-File (see attachment), but it has 0 kB.

Do I need MS-WORD have installed or can I do this with LibreOffice also?
 

Attachments

  • TEST.zip
    152 bytes · Views: 218

JOTHA

Well-Known Member
Licensed User
Longtime User
THX Erel,
here is the project.
 

Attachments

  • PoiWord.zip
    1.1 KB · Views: 230
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
  • B4J-Version: 7.32
  • Java: jdk1.8.0_192
  • Windows10
Release-Mode tested with error
Debug-Mode stops at:
B4X:
doc.RunMethod("write", Array(out))
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
I made a download again of the Library-Files and the PoiExcelExample too.
I copied them into the Library-Directory of B4J ... but it really doesn't work!

The PoiExcelExample alos doesn't work, see LOG-file:
main._createworkbook (java line: 82)
org.apache.poi.ooxml.POIXMLException: org.apache.poi.ooxml.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:602)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.createSheet(XSSFWorkbook.java:896)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:682)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:92)
at anywheresoftware.b4j.objects.PoiWorkbookWrapper.AddSheet(PoiWorkbookWrapper.java:82)
at b4j.example.main._createworkbook(main.java:82)
at b4j.example.main._appstart(main.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:37)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.poi.ooxml.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.ooxml.POIXMLFactory.newDocumentPart(POIXMLFactory.java:111)
at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:587)
... 22 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
at org.apache.poi.ooxml.POIXMLFactory.newDocumentPart(POIXMLFactory.java:109)
... 23 more
Caused by: java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl.generatedSetterHelperImpl(Lorg/apache/xmlbeans/XmlObject;Ljavax/xml/namespace/QName;IS)Lorg/apache/xmlbeans/XmlObject;
at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl.setColsArray(Unknown Source)
at org.apache.poi.xssf.usermodel.helpers.ColumnHelper.cleanColumns(ColumnHelper.java:66)
at org.apache.poi.xssf.usermodel.helpers.ColumnHelper.<init>(ColumnHelper.java:46)
at org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentCreate(XSSFSheet.java:259)
at org.apache.poi.xssf.usermodel.XSSFSheet.<init>(XSSFSheet.java:187)
... 29 more
:(

Now i'm installing the newer jdk-8u212-windows-x64 in C:\Java ... maybe that is the reason ... --> NO! --> this didn't help!

In the protocol there is a message (see picture),
means "Lib not in use!"
Protocol-Warning.png
 
Last edited:
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
I have now installed B4J on another PC and there are the same problems.
The LOG-File in Debug-Mode gives more information:
Waiting for debugger to connect...
Program started.
Fehler in Zeile: 55 (Main)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main._savedocument(main.java:150)
at b4j.example.main._appstart(main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:29)
Caused by: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
at org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43)
at org.apache.poi.xwpf.usermodel.XWPFDocument.commit(XWPFDocument.java:811)
at org.apache.poi.ooxml.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:462)
at org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:236)
... 22 more
Program terminated (StartMessageLoop was not called).

Maybe the problem is caused by downloading the additional jar-files which are needed:
  1. commons-collections4-4.1.jar
  2. commons-compress-1.18.jar
  3. commons-math3-3.6.1.jar
  4. poi-4.0.0.jar
  5. poi-ooxml-4.0.0.jar
  6. poi-ooxml-schemas-4.0.0.jar
  7. poi-scratchpad-3.12-20150511.jar
  8. xbean.jar
Do I have to copy also some XML-Files to the Library-folder?
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
THX Erel,

i tried the attached project ... the same problem again :(
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
Please post the stack trace.
How can i get this?
... or do you mean the LOG-file (Protokoll / protocol)?

I found he code for showing the Stack Trace:
Log Stack Trace ###############################
From Sub AppStart
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
b4j.example.main.main(main.java:28)
7 items Listed #######################
before SaveDocument
main._savedocument (java line: 228)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main._savedocument(main.java:228)
at b4j.example.main._appstart(main.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
Caused by: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
at org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43)
at org.apache.poi.xwpf.usermodel.XWPFDocument.commit(XWPFDocument.java:811)
at org.apache.poi.ooxml.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:462)
at org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:236)
... 14 more
 
Last edited:
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
THX Erel,

i had a look in the PC an there was the "DOCUMENT.DOCX" as expected ... it works!
Later I'll do as you told me ...
Delete all relevant libraries, make sure that there are no old copies in the internal libraries folder and download them again

Thank you very much!
 
Upvote 0
Top