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

Free Support Forum - aspose.com

Nullpointer exception in saveAsTiff

We are using the Aspose components in an application running on WebSphere Application Server 7 for Windows. At some point conversion to TIFF stops working in the PDF converter.

If we call the converter in a loop, it works well for 20 to 30 conversions, and then a null pointer exception is thrown. After that the same null pointer exception is thrown on every conversion, and we have to restart the application to convert any PDF file.

We have tried with different pdf files, and it seems to occur using any PDF file no matter the size of the files.

Code for converter is:
PdfConverter pdfConverter = new PdfConverter();
try {
pdfConverter.setResolution(new Resolution(300));
pdfConverter.bindPdf(inputFilestream);
pdfConverter.doConvert();
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.setCompression(CompressionType.LZW);
pdfConverter.saveAsTIFF(outputFilename, tiffSettings);
} finally {
pdfConverter.close();
}

Exception from component is:
Caused by: java.lang.NullPointerException
at com.aspose.ms.System.j.b(Unknown Source)
at com.aspose.ms.System.j.a(Unknown Source)
at com.aspose.ms.System.j.sort(Unknown Source)
at com.aspose.ms.System.j.sort(Unknown Source)
at com.aspose.ms.c.g.bf.a(Unknown Source)
at com.aspose.ms.c.g.b.writeToSequence(Unknown Source)
at com.aspose.ms.core.a.a.b.a.a(Unknown Source)
at com.aspose.ms.System.d.b.a(Unknown Source)
at com.aspose.ms.System.d.aa.a(Unknown Source)
at com.aspose.pdf.b.k.b.c.m.o(Unknown Source)
at com.aspose.pdf.devices.TiffDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.DocumentDevice.process(Unknown Source)
at com.aspose.pdf.facades.PdfConverter.a(Unknown Source)
at com.aspose.pdf.facades.PdfConverter.saveAsTIFF(Unknown Source)

We are using version 9.0 of PDF component, but nullpointer exception also occurs when using v9.1 and v4.5.1.

We have also tried:
- using com.aspose.pdf.devices.DocumentDevice.process method for conversion
- raising heap memory allocation
All with null pointer exception at some point.

The same pattern occurs when using Imaging v2.1:

Code for converter is:
Image image = Image.load(inputFilestream);
TiffOptions options = new TiffOptions();
options.setCompression(TiffCompressions.Lzw);
options.setPhotometric(TiffPhotometrics.Rgb);
int[] s = {8, 8, 8};
options.setBitsPerSample(s);
image.save(outputFilename, options);

A nullpointer exception is thrown after about 30 successful conversions, and after that no images can be converted without nullpointer exception.

Caused by: java.lang.NullPointerException
at com.aspose.imaging.internal.ms.System.c.b(Unknown Source)
at com.aspose.imaging.internal.ms.System.c.a(Unknown Source)
at com.aspose.imaging.internal.ms.System.c.a(Unknown Source)
at com.aspose.imaging.internal.ms.System.c.b(Unknown Source)
at com.aspose.imaging.fileformats.tiff.TiffFrame.save(Unknown Source)
at com.aspose.imaging.internal.bz.p.export(Unknown Source)
… 81 more

Do you have suggestions, what could cause the nullpointer exceptions?



Hi Jan,


Thanks for your inquiry. Is your application using multithreaded approach? As we have noticed such issues when a document is being accessed in more than one threads. Aspose APIs do support Multithreading and you may create multi-threaded applications using these APIs. But, these are multi-thread safe as long as only one thread works on a document at a time. If you manipulate a single document in different threads, the results would be unstable.

If you are not using multithreaded approach then please share some more details about your scenario to replicate the issue.

We are sorry for the inconvenience caused.

Thank you.

Hi Tilal,

Thanks for your reply.

No multithreaded approach is used. But now I did testing using different JREs, and the exception was only produced on the WebSphere JRE. The WebSphere JRE used is from WebSphere 7.0.0.31 64bit for Windows. (31 is most recent fixpack)

The exception occurs every time in the following loop no matter which pdf file is used.

for (int x=0;x<50;x++) {
PdfConverter pdfConverter = new PdfConverter();
try {
pdfConverter.setResolution(new Resolution(300));
pdfConverter.bindPdf(“C:/temp/1.pdf”);
pdfConverter.doConvert();
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.setCompression(CompressionType.LZW);
pdfConverter.saveAsTIFF(“C:/temp/1.tif”, tiffSettings);
} finally {
pdfConverter.close();
}
}

Hi Jan,


Thanks for your feedback. We are looking into your issue and will get back with our findings soon.

Best Regards,

Hi Jan,


Thanks for your patience. We have downloaded the IBM development package for Eclipse and tested the scenario using your shared code over Windows 7 64 bit with Aspose.Pdf for Java 9.1.0. I am afraid we are unable to replicate the issue. Could you please test the scenario over some other machine and share the results?

We are truly sorry for the inconvenience.

Best Regards,

Hi,

Thanks for your reply. WebSphere 7 is running Java 6 and not the Java 7 in your reply. I have attached image with version information. For now I have continued to test on our AIX test environment, as the solution we are building is for an AIX environment, and this problem only occurs on Windows. So it is not critical to us. When I have time, I will try it on another Windows machine to verify, and return the result to you.

Best regards

Hi Jan,


Thanks for your feedback. Actually Java 7 is bundled in IBM development package for Eclipse, that we used for testing the scenario. It is good to know that Aspose.Pdf for Java is working fine for you on AIX environment. However, we are looking forward to your findings over Windows for further investigation.

Best Regards,