B4J Question xls.InitializeExisting - crash only on standalone package

a n g l o

Active Member
Licensed User
Longtime User
hi, the folwing runs ok from the ide both in debug and release mode.
when i use 'Build Standalone Package' (b4j 8.9, jdk 11.0.1, win10), the exe file crash right after the OK MsgBox (i don't see the Try-Catch MsgBox, I dont see the END MsgBox):

open a new b4j ui project, add jPoi library.

add the folwing code to existing default code :
B4X:
#PackagerProperty: AdditionalModuleInfoString = opens schemaorg_apache_xmlbeans.system.sD023D6490046BA0250A839A9AD24C443;

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
End Sub

Sub Button1_Click
            loadXlsx
End Sub

Private Sub loadXlsx
            Dim xls As PoiWorkbook
            If File.Exists(File.DirApp,"1.xlsx")=True Then File.Delete(File.DirApp,"1.xlsx")
            File.Copy(File.DirAssets,"1.xlsx",File.DirApp,"1.xlsx")
            fx.Msgbox(MainForm,"ok till here","MsgBox_OK")
            Try
                    xls.InitializeExisting(File.DirApp ,"1.xlsx","")
            Catch
                    fx.Msgbox(MainForm,LastException.Message,"MsgBox_ERROR")
            End Try
            fx.Msgbox(MainForm,"file loaded","MsgBox_END")
End Sub

NOTE : in order to see the crash you MUST build a Standalone Package and run the exe !

i've done that be4 with no problem. i'm sure i'm forgetting something. thank you
 

DonManfred

Expert
Licensed User
Longtime User
run the debug.bat and post the full error.
 
Upvote 0

a n g l o

Active Member
Licensed User
Longtime User
forgot to mention that the xlsx file was added to the project. here's the debug_bat :
B4X:
C:\tmp\1\Objects\temp\build>cd bin

C:\tmp\1\Objects\temp\build\bin>java.exe @release_java_modules.txt  -m b4j/b4j.example.main
main._loadxlsx (java line: -1)
java.lang.ClassCastException: class java.lang.ExceptionInInitializerError cannot be cast to class java.lang.Exception (java.lang.ExceptionInInitializerError and java.lang.Exception are in module java.base of loader 'bootstrap')
        at b4j/anywheresoftware.b4a.BA.setLastException(Unknown Source)
        at b4j/b4j.example.main._loadxlsx(Unknown Source)
        at b4j/b4j.example.main._button1_click(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)


C:\tmp\1\Objects\temp\build\bin>pause
Press any key to continue . . .
 
Upvote 0

a n g l o

Active Member
Licensed User
Longtime User
:
B4X:
C:\tmp\1\Objects\temp\build>cd bin

C:\tmp\1\Objects\temp\build\bin>java.exe @release_java_modules.txt  -m b4j/b4j.example.main
main._loadxlsx (java line: -1)
java.io.IOException
        at b4j/org.apache.poi.ss.usermodel.WorkbookFactory.createWorkbook(Unknown Source)
        at b4j/org.apache.poi.ss.usermodel.WorkbookFactory.createXSSFWorkbook(Unknown Source)
        at b4j/org.apache.poi.ss.usermodel.WorkbookFactory.create(Unknown Source)
        at b4j/anywheresoftware.b4j.objects.PoiWorkbookWrapper.InitializeExisting(Unknown Source)
        at b4j/b4j.example.main._loadxlsx(Unknown Source)
        at b4j/b4j.example.main._button1_click(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
        at b4j/org.apache.poi.ss.util.CellReference.<init>(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFCell.<init>(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFRow.<init>(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFSheet.initRows(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFSheet.read(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentRead(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFWorkbook.parseSheet(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(Unknown Source)
        at b4j/org.apache.poi.ooxml.POIXMLDocument.load(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(Unknown Source)
        at b4j/org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        ... 19 more
Caused by: java.nio.charset.UnsupportedCharsetException: Big5
        at java.base/java.nio.charset.Charset.forName(Unknown Source)
        at b4j/org.apache.poi.util.StringUtil.<clinit>(Unknown Source)
        ... 35 more


C:\tmp\1\Objects\temp\build\bin>pause
Press any key to continue . . .
 
Upvote 0
Top