java.lang.NoClassDefFoundError Upon Workbook constructor invocation

Hi,


This error happens sometimes, don’t know to define the differentiating circumstance.

Are you familiar with this error? What is the reason?

The error is generated when this line is called:

<span style=“font-family: “Courier New”; font-size: 10.8pt; color: rgb(102, 14, 122); font-weight: bold;”>workbook <span style=“font-family: “Courier New”; font-size: 10.8pt; background-color: rgb(255, 255, 255);”>= <span style=“font-family: “Courier New”; font-size: 10.8pt; color: rgb(0, 0, 128); font-weight: bold;”>new <span style=“font-family: “Courier New”; font-size: 10.8pt; background-color: rgb(255, 255, 255);”>Workbook(getClass().getResourceAsStream(<span style=“font-family: “Courier New”; font-size: 10.8pt; color: rgb(102, 14, 122); font-weight: bold; font-style: italic;”>EXCEL_TEMPLATE<span style=“font-family: “Courier New”; font-size: 10.8pt; background-color: rgb(255, 255, 255);”>));

workbook is a class member of type <span style=“font-family: “Courier New”; font-size: 10.8pt; background-color: rgb(228, 228, 255);”>Workbook. <span style=“color: rgb(102, 14, 122); font-style: italic; font-weight: bold; font-family: “Courier New”; font-size: 10.8pt; background-color: rgb(255, 255, 255);”>EXCEL_TEMPLATE is a constant refering to an xlsx file in the jar.

Following is the top potion of the stack trace (starting with the failing CTOR call):

"java.lang.NoClassDefFoundError: Could not initialize class sun.java2d.Disposer sun.java2d.Disposer.addRecord(Disposer.java:110)
sun.awt.image.BufImgSurfaceData.initRaster(Native Method)
sun.awt.image.BufImgSurfaceData.createDataIC(BufImgSurfaceData.java:258)
sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:91)
sun.awt.image.BufImgSurfaceManager.(BufImgSurfaceManager.java:55)
sun.awt.image.SurfaceManager.getManager(SurfaceManager.java:79)
sun.java2d.SurfaceData.getPrimarySurfaceData(SurfaceData.java:273)
sun.java2d.SunGraphicsEnvironment.createGraphics(SunGraphicsEnvironment.java:185)
sun.java2d.HeadlessGraphicsEnvironment.createGraphics(HeadlessGraphicsEnvironment.java:89)
java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1182)
java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
com.aspose.cells.b.a.b.zi.a(Unknown Source)
com.aspose.cells.a.d.zfq.A(Unknown Source)
com.aspose.cells.a.d.zfq.a(Unknown Source)
com.aspose.cells.WorksheetCollection.(Unknown Source)
com.aspose.cells.Workbook.a(Unknown Source)
com.aspose.cells.Workbook.(Unknown Source)

Thanks, Neva

Hi,


Thanks for providing us stack trace.

Well, we are not entirely certain about your issue. We need your template Excel file to evaluate or reproduce the issue on our end. It looks like you have embedded Excel file into the jar, so you may extract the file from the jar and then send it (via attachment) to us here. Alternatively, you can just read data from the streams and save data into an Excel file and then send us the file.

Thank you.

Attaching the excel


Thank you, Neva

Hi,


Thanks for the template file.

Please try our latest version/fix: Aspose.Cells for Java v8.9.0.7

I have simply tested your scenario/ case a bit using your template file with v8.9.0.7, it works fine and I do not get any exception:
e.g
Sample code:

Workbook workbook = new Workbook(“tmpl_excel.xlsx”);

Let us know if you still have any issue.

Thank you.