We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

java.lang.IncompatibleClassChangeError: Found interface sun.font.FontManager- but class was expected

I am getting exception with Aspose. I use version 7.0.1.

Code piece :

// importutil class contains :

public Workbook getWorkBook() {

return workBook;

}

/**

* @param workBook

* @throws TDAException

*/

public void setWorkBook(Workbook workBook, String fileType)

throws TDAException {

this.workBook = workBook;

try {

if (XLS.equalsIgnoreCase(fileType)) {

this.workBook.setFileFormat(FileFormatType.EXCEL_97_TO_2003);

} else {

this.workBook.setFileFormat(FileFormatType.XLSX);

}

} catch (Exception e) {

LOGGER.error(e);

throw new TDAException(e);

}

}

Workbook workbook = importutil.getWorkBook();

ByteArrayOutputStream ms=new ByteArrayOutputStream();

try {

workbook.save(ms, FileFormatType.XLSX);

} catch (Exception e) {

TDALOG.error(e);

throw new TDAException(e);

}

byte[] fileContent = ms.toByteArray();

ms.close();

...................

I am below exception at "wrokbook.save() :

java.lang.IncompatibleClassChangeError: Found interface sun.font.FontManager, but class was expected
at com.aspose.cells.a.c.cf.p(Unknown Source)
at com.aspose.cells.a.c.cf.(Unknown Source)
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.pk.a(Unknown Source)
at com.aspose.cells.pk.a(Unknown Source)
at com.aspose.cells.pk.a(Unknown Source)
at com.aspose.cells.Worksheet.autoFitRow(Unknown Source)
at com.aspose.cells.kw.a(Unknown Source)
at com.aspose.cells.fA.a(Unknown Source)
at com.aspose.cells.fA.v(Unknown Source)
at com.aspose.cells.fA.a(Unknown Source)
at com.aspose.cells.fz.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at caf.opm.sec.tda.service.impl.LiquidityPictureServiceImpl.saveLiqPictureExportedFile(LiquidityPictureServiceImpl.java:593)
at caf.opm.sec.tda.service.impl.LiquidityPictureServiceImpl.liquidityPictureExportToExcel(LiquidityPictureServiceImpl.java:492)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:291)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:180)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:147)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:169)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:169)
at $Proxy97.liquidityPictureExportToExcel(Unknown Source)
at caf.opm.sec.tda.controller.LiquidityPictureController.liquidityPictureExportData(LiquidityPictureController.java:169)
at caf.opm.sec.tda.controller.LiquidityPictureController.liquidityPictureExport(LiquidityPictureController.java:94)
at caf.opm.sec.tda.controller.LiquidityPictureControllerTest.liquidityPictureExportDataTest(LiquidityPictureControllerTest.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Please provide the solution

Hi,


Please try our latest version/fix: Aspose.Cells for Java v8.1.2.4 and use latest APIs in it accordingly.
If you still find the issue, kindly do create a complete sample JAVA program (runnable) to post us here to reproduce the issue on our end, we will check it soon.
Thank you.

Hello Amjad,

Thanks for your reply.

I face this issue when i run withJunit Test class. Is there any specific setting or reason why it is failing here.

Hi,

Well, there is no specific setting needed regarding Aspose.Cells on Jnit test cases, it should equally work fine too.

Thank you.

Hi,

Thanks for using Aspose.Cells.

It seems the used version/vendor of the jvm was not detected correctly by
the java application. Please using following jvm option when starting your
application to test whether it can work:

-Djava.awt.headless=true

or

-DAspose.Cells.Disable=SunFontManager