B4J Question Caused by: java.lang.ClassNotFoundException: org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory

oldeast

Active Member
Licensed User
Longtime User
Hi all,
This program has been running ok for several years with no problem.
The latest compile has an error which occurs when trying to open an excel file (32 rows).
Previous versions which have been working ok, now also produce this error.
I have tried cleaning the project.
I have tried another excel file.
Using jPoi 5.01 B4J 9.3 Java 11
Thanks,
Graham
java.lang.NoClassDefFoundError: org/openxmlformats/schemas/drawingml/x2006/main/ThemeDocument$Factory
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61)
at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:660)
at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:165)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:278)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:118)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:98)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:36)
at org.apache.poi.ss.usermodel.WorkbookFactory.lambda$create$2(WorkbookFactory.java:199)
at org.apache.poi.ss.usermodel.WorkbookFactory.wp(WorkbookFactory.java:295)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:199)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:163)
at anywheresoftware.b4j.objects.PoiWorkbookWrapper.InitializeExisting(PoiWorkbookWrapper.java:84)
at b4j.example.main._openworkbook(main.java:607)
at b4j.example.main._btnfile_action(main.java:526)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:234)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 36 more
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/openxmlformats/schemas/drawingml/x2006/main/ThemeDocument$Factory
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:138)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:234)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoClassDefFoundError: org/openxmlformats/schemas/drawingml/x2006/main/ThemeDocument$Factory
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61)
at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:660)
at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:165)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:278)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:118)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:98)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:36)
at org.apache.poi.ss.usermodel.WorkbookFactory.lambda$create$2(WorkbookFactory.java:199)
at org.apache.poi.ss.usermodel.WorkbookFactory.wp(WorkbookFactory.java:295)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:199)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:163)
at anywheresoftware.b4j.objects.PoiWorkbookWrapper.InitializeExisting(PoiWorkbookWrapper.java:84)
at b4j.example.main._openworkbook(main.java:607)
at b4j.example.main._btnfile_action(main.java:526)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
... 9 more
Caused by: java.lang.ClassNotFoundException: org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 36 more
 

oldeast

Active Member
Licensed User
Longtime User
Thank you.
I didn't post it because the code has been running for 3+ years until the last compilation.
Older posts with this error were fixed by a Ctr+p, but it didnt work for me.


Open Workbook:
    txtErrors.Text="":txtErrors.visible=False
    HdrList.Initialize
    HdrList.AddAll(Array As String("Surname" , "GivenName" , "Age" , "BirthDate", "PlaceOfBirth" , "DeathDate" , "BurialDate" , "CremationDate" , "BurialPlaceOrCremation" , "PlaceOfDeath" , "Occupation" , "RegNumber" , "Transcription" , "Comments" ))
    Dim fc As FileChooser                 ' Use filechooser from jFX library
    Dim fileSelected As String            ' File selected. If selected full path is returned else ""
    Dim n,p As String
    fc.Initialize
    fc.InitialDirectory = GetSystemProperty("user.home", "c:\")      ' Set starting folder
    fc.Title = "Select an Excel File..."
    fc.SetExtensionFilter("Excel files..",Array As String("*.xls","*.xlsx"))
    fileSelected = fc.ShowOpen(MainForm) ' Show the dialog and select
    'Return fileSelected
    Dim fileO As JavaObject
    fileO.InitializeNewInstance("java.io.File", Array As Object(fileSelected))

    Dim n As String = fileO.RunMethod("getName",Null)
    Dim p As String = fileO.RunMethod("getPath", Null)
    p = p.Replace(n, "")

    poi.InitializeExisting(p,n,"",False)
    sheet=poi.GetSheet(0)
 

    Dim lst1 As List
    lst1.Initialize
    lst1.AddAll(sheet.GetRow(0).Cells)
 
    For i = 0 To lst1.Size - 2
        Dim pc As PoiCell = lst1.Get(i)
        Dim s As String = HdrList.Get(i)
        Log(pc&" "& s)
        If pc.Value <> s Then
            Dim x As Int=i+1
            fx.Msgbox2(Null, "Column " & x &" header name is " & pc.Value & " but should be " & s &". Please correct the File and try again.","Column Name Error" ,"OK","","",fx.MSGBOX_WARNING)
            Return
        End If
    Next
    'get the number of rows
    LastRow=sheet.LastRowNumber

rows=LastRow
    txtFilePath.Text=p:txtFile.text=n
    fx.Msgbox(Null,"Column headers are correct." & CRLF & "There are " & rows & " rows ready for import","File Ready" )
End Sub
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Ok, I have another program, with similar code, I compiled it and it opens excel Ok
I did restart windows 11 btw
 
Upvote 0
Top