Exception "NoSuchMethodError: com.ctc.wstx.api.."


Hello,

I expreienced this error: ( I have trying to migrate to new Aspose.Cells 7 )
my code, seems like it is due to:
FileFormatType.EXCEL_2007_XLSX


ByteArrayOutputStream out = new ByteArrayOutputStream();

try
{
workbook.save( out, FileFormatType.EXCEL_2007_XLSX );
}
catch( Exception exception )
{

}


java.lang.NoSuchMethodError: com.ctc.wstx.api.WriterConfig.doAddSpaceAfterEmptyElem(Z)V
at com.aspose.cells.b.a.h.k.a(Unknown Source)
at com.aspose.cells.b.a.h.k.(Unknown Source)
at com.aspose.cells.b.a.h.k.(Unknown Source)
at com.aspose.cells.fN.a(Unknown Source)
at com.aspose.cells.fN.p(Unknown Source)
at com.aspose.cells.fN.a(Unknown Source)
at com.aspose.cells.fM.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)


My problem looks like this also:

<a href="https://forum.aspose.com/t/123368</a></div></div><div><br></div><div>P.S. Please not, I have no error with: FileFormatType.EXCEL_97_TO_2003</div>

aslo not working (with):
XlsSaveOptions saveOptions = new XlsSaveOptions();
saveOptions.setSaveFormat( SaveFormat.XLSX );

workbook.save( out, saveOptions );

Hi,


Please make sure that you have also set all other dependencies jars (e.g., dom4j-1.6.1.jar, bcprov-jdk15-146.jar,woodstox-core-asl-4.0.8.jar, stax2-api-3.0.2, jsr173_1.0_api.jar) to class path. I have tested your case with our latest version, v7.0.2 using my JDK1.5 version, it works fine. Also for reference about all the JARs, see the “README_LIB.txt” file present in the release archive of v7.0.2:
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/default.aspx

Here is my sample code, I even open an XLS file and save to XLSX format:
FileInputStream fis = new FileInputStream(“testXLS.xls”);
Workbook wb=new Workbook(fis,new LoadOptions(LoadFormat.AUTO));
fis.close();
wb.getWorksheets().get(0).getCells().get(1,0).setValue(“This works!”);
FileOutputStream fos = new FileOutputStream(new File(“outtestXLSX1.xlsx”));
wb.save(fos, new OoxmlSaveOptions(SaveFormat.XLSX));
fos.close();


Thank you.

HI,

Thank you for your response.


I have checked dependecies from libraries, ( I have all listed libraries in my application )
I have just installed new version 7.0.2 ( previously I used 7.0.1.5 ),
but I experienced same error.

As I understood class belong to library: woodstox-core-asl-4.1.1 ?? yes?
So I need to focus on this library?

Could be the reason of problem If I also have another libraries in my classpath,
and they may confilct?

I have copied these libraries into JBoss folder: jboss-5.0.1.GA\server\application\lib
bcprov-jdk16-146.jar
stax2-api-3.0.2.jar
woodstox-core-asl-4.1.1.jar
dom4j-1.6.1.jar

but I have not isntalled
jsr173_1.0_api.jar ( I'm using JDK 1.6, and it is written in Readme that I don't need to use it )

Exception is still thrown here:
workbook.save( out, new OoxmlSaveOptions( SaveFormat.XLSX ) );

Here is full code: (and realy seems like it works If I will run it without apllication server via main class )

Workbook workbook = createWorkbook( report.getPageCount() );


private Workbook createWorkbook( int pageCount )
{
Workbook workbook = new Workbook();

WorksheetCollection worksheets = workbook.getWorksheets();
int worksheetsCount = worksheets.getCount();
if( worksheetsCount < pageCount )
{
for( int i = worksheetsCount; i < pageCount; i++ )
{
worksheets.add ();
}
}
else if( worksheetsCount > pageCount )
{
while( worksheetsCount != pageCount )
{
worksheets.removeAt( worksheetsCount - 1 );
worksheetsCount = worksheets.getCount();
}
}

// Contains data for charts
worksheets.add ();

return workbook;
}


protected byte[] getBytes()
{
ByteArrayOutputStream out = new ByteArrayOutputStream();

try
{
workbook.save( out, new OoxmlSaveOptions( SaveFormat.XLSX ) );
}
catch( Exception exception )
{

}

return out.toByteArray();
}

Yes, seems like problem with woodstox-core-asl-4.1.1

I have found problem: ( I have 3 (two) WSTX libraries at the same time in JBoss class path )

C:\Program Files\jboss-5.0.1.GA\lib\wstx.jar
C:\Program Files\jboss-5.0.1.GA\client\wstx.jar

I also have by default in main JBoss folder another wsts library
(and it is used with higher priority then library in my application libraries folder)

So I have just replcaed old one (wstx.jar to new one with same name),
and installed new one from Aspose.Cells archive.

Now it works.

Thank you.

Hi,

It is quite possible that you have another library for “woodstox-core...” and its version is different from what our Aspose.Cells component needs. Please check all libraries used in your server, and put jars that are used by specific application into its own "WEB-INF/lib". Thus it, should be available to avoid some conflicts.

Thank you.

Hi,


Yes, good to know that you have sorted out issue now.

Thank you.