For xlsx getting NullPointerException when using webservices-rt.jar (metro project java)


We have temporary license for non-commercial use only (version 7.0.2) and our application web based.
When simple standalone program (given below) is run to open an XLS or XLSX file there is no problem. But when we deploy in web application and try to open XLSX file we end but with NullPointerException (given below).
When we drilled down we came up with an finding that in our web application we have webservices-rt.jar (from metro project version 2.0.1) and woodstox-core-asl-4.1.1.jar, which causes the problem. The problem comes up when we have webservices-rt.jar to the classpath before woodstox-core-asl.4.1.1.jar.
As we are using Eclipse we can order the jar files in the classpath which is not same for web based application, so if in the order, we have “webservices-rt.jar” as first then we have NullPointerException and when we change the order and keep “woodstox-core-asl-4.1.1.jar” first then program runs fine.
We have been using “webservices-rt.jar” for webservices in our application, and we had to add “woodstox-core-asl-4.1.1.jar” as aspose needs it.

Note: NullPointerException only comes up opening an XLSX file and not XLS.

Steps to reproduce
1. Create simple project in Eclipse (any other IDE).
2. Copy the below code which opens the xls/xlsx file.
3. add the jar files needed, in our case below are the jar files
a. aspose-cells-7.0.2.jar
b. dom4j-1.6.1.jar
c. stax2-api-3.0.2.jar
d. webservices-rt.jar
e. woodstox-core-asl-4.1.1.jar
4. Make sure webservices-rt.jar comes first in the classpath order, using eclipse we can set the order as below
a. Right click on the project properties
b. Go to Java Build Path, there select “Order and Export” tab
c. Set the order required
5. Set webservices-rt.jar beofre woodstox-core-asl-4.1.1.jar, and run the program, we end up in NullPointerException, now change the order and set woodstox-core-asl-4.1.1.jar before webservices-rt.jar, program runs fine.


Standalone Application:
public class AsposeXLSXReadTest {
public static void main(String[] args) throws Exception {
FileInputStream fis = null;
Workbook wb = null;

fis = new FileInputStream(“F:\downloads\Book2.xlsx”);
wb = new Workbook(fis, new LoadOptions(LoadFormat.AUTO));
System.out.println(“Data in A1:”" + wb.getWorksheets().get(0).getCells().get(0, 0).getStringValue() + “”");
fis.close();

System.out.println(“Success!”);
}
}

Stack Trace:
Exception in thread “main” java.lang.NullPointerException
at com.aspose.cells.kp.a(Unknown Source)
at com.aspose.cells.kw.e(Unknown Source)
at com.aspose.cells.kw.a(Unknown Source)
at com.aspose.cells.kv.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at AsposeXLSXReadTest.main(AsposeXLSXReadTest.java:13)

Hi,


Please provide us your webservices-rt.jar file, so that we could evaluate your issue soon.

Thank you.

Hi,
You can find the jars from java metro porject at Java Net Metro Project 2.0.1. You can find webservices-rt.jar in lib folder.

thanks,
Mahesh Pujari

Hi,


Thanks for providing us the project containing the required jars.

We will look into your issue soon.

Thank you.

Hi,
May I know any updates on this issue (and if this is an issue), just for your information the package “com.ctc.wstx.*” is common in both the jar files.

thanks,
Mahesh Pujari

Hi,


I have asked the concerned developer to update on it soon. A ticket is already logged for investigation with an id: CELLSJAVA-40015 into our database. Once we have any update on it, we will let you know.

Thank you.

Hi,


To update you further we have found the issue. The issue should be caused by the different implementation of “com.ctc.wstx.*” in webservices-rt.jar. Even if you remove the woodstox-core-asl-4.1.1.jar from the classpath, the same Exception will be thrown when reading XLSX files. We will try our best to solve those issues we can find with webservices-rt.jar to make our component compatible with the implementation of “com.ctc.wstx.*” in it and provide a new fix for your needs soon. However, because webservices-rt.jar is not the common library we can provide to common users, the test and solution may be not enough for solving all such kind of issues completely. So it will be better if you can change your classpath for your server to use “com.ctc.wstx.*” in woodstox-core-asl-4.1.1.jar instead of those in webservices-rt.jar.


Thanks for your understanding!

Hi,
Before posting the issue we had this fix locally by making sure that “woodstox-core-asl-4.1.1.jar” comes before webservice-rt.jar in the classpath, had to make a tweak by renaming “woodstox-core-asl-4.1.1.jar” as “awoodstox-core-asl-4.1.1.jar”, which made sure that in jboss 6 and OS windows, it picked up awoodstox-core-asl-4.1.1.jar first rather then webservice.jar, but not sure if this fix will work on linux (not tested it yet).
Just wanted to know what are your plans for aspose to integrate with webservice-rt, I think there should be some properties setting where we can set our “com.ctc.wstx.*” implementation, so that we in the future can just remove any one of the jar’s from the path.

thanks,
Mahesh Pujari

Hi,


We will update you soon here.

Thanks for being patient!

Hi,

Please try the new fixed version: v7.0.2.4

We have changed our code to avoid those non-compatible features of different implementations of “com.ctc.wstx.*”. Please try the new fix


Thank you.

The issues you have found earlier (filed as CELLSJAVA-40015) have been fixed in this update.

The issues you have found earlier (filed as CELLSJAVA-40015) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,
The issue got fixed, thanks for the update.

thanks and regards,
Mahesh Pujari