Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Sep 23, 2025 11:42 am

I am evaluating the use of Spire.PDF for Java for our enterprise application to perform PDF to PDF/A conversion. Testing the PDF to PDF/A Conversion using Spire.PDF locally (in Eclipse using JDK 21 on Windows) has produced good results using version:

Code: Select all
        <dependency>
            <groupId>e-iceblue</groupId>
            <artifactId>spire.pdf</artifactId>
            <version>11.8.3</version>
        </dependency>


However when trying to run PDF to PDF/A Conversion in our enterprise environment: OSGi/Karaf/JDK 21/Windows, there is a strange exception:

Code: Select all
java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "arg0" is null
at com.spire.pdf.packages.sprmsv.spr┌?(MemoryStream.java:424)
at com.spire.pdf.packages.sprzov.spr??(Assembly.java:40)
at com.spire.pdf.packages.sprpro.spr┴?(Unknown Source)
at com.spire.pdf.packages.spruuo.spr??(Unknown Source)
at com.spire.pdf.packages.spruuo.spr??(Unknown Source)
at com.spire.pdf.packages.sprwro.spr??(Unknown Source)
at com.spire.pdf.packages.sprfto.spr??(Unknown Source)
at com.spire.pdf.packages.sprfto.spr??(Unknown Source)
at com.spire.pdf.conversion.PdfStandardsConverter.spr??(Unknown Source)
at com.spire.pdf.conversion.PdfStandardsConverter.toPdfA3B(Unknown Source)
at com.seeburger.bic.pdfa3composer.PDFAConverter.convertViaSpire(PDFAConverter.java:292)
at com.seeburger.bic.pdfa3composer.PDFAConverter.doConversionViaSpirePDF(PDFAConverter.java:260)
at com.seeburger.bic.pdfa3composer.PDFAConverter.doConversion(PDFAConverter.java:109)
at com.seeburger.bic.pdfa3composer.AdapterProcessor.execute(AdapterProcessor.java:152)


I have already ruled out trivial issues such as our code passing wrong/null/empty PDF data to convert (as a stream). The code to convert PDF to PDF/A can be reduced to just a few lines when using memory streams (just for a test):

Code: Select all
import com.spire.pdf.conversion.PdfStandardsConverter;


Code: Select all
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PdfStandardsConverter conv = new PdfStandardsConverter(new ByteArrayInputStream(inBytes));
conv.getOptions().setPreserveAllowedMetadata(true);
conv.toPdfA3B(bos);
bos.close();


I hope some expert from e-iceblue can help here: for instance if there is a way to de-obfuscate the code in packages sprmsv, sprzov etc. it may give a clue as to the problem.

seeburger
 
Posts: 5
Joined: Thu Sep 18, 2025 10:19 am

Wed Sep 24, 2025 10:14 am

Hello,

Thank you for your inquiry.
While testing within the OSGi framework, I encountered an issue where com.spire.pdf.conversion cannot be found. Although this differs slightly from the error you reported. In your project, is there any error if you simply create a Hello Word.pdf file? I'm worried that there may be some differences between my project settings and yours, could you please provide the input file that triggers the issue, along with more details about your OSGi framework settings? You may upload the files as attachments or send them directly to my email: [email protected]. Thanks in advance.
Sincerely,
Talia
E-iceblue support team
User avatar

talia.liu
 
Posts: 331
Joined: Mon Apr 14, 2025 3:33 am

Thu Sep 25, 2025 9:43 am

I have written a mail because I cannot share URLs via the forum. Some attachments to provide are large and download URLs to Open Source projects like Apache Karaf had to be provided. Thank you for your help in diagnosing the issue. This is a priority for us because our enterprise server product requires an Apache Karaf OSGi environment.

If the mail is not received properly – please write a reply here...

Best Regards,
Ivan Vaklinov
 
BG Business Integration Converter Group, Seeburger Corporation
SEEBURGER INFORMATIK EOOD, 16-A Dr G.M.Dimitrov blvd. Izgrev Distr Sofia , 1797 Bulgaria
SEEBURGER AG - Edisonstr.1 , D-75015 Bretten, Germany
[email protected]
    

seeburger
 
Posts: 5
Joined: Thu Sep 18, 2025 10:19 am

Thu Sep 25, 2025 10:13 am

Problem details with no large attachments or URLs: The Sipre.PDF JAR as distributed by e-iceblueis not an OSGi bundle and cannot be directly used in an OSGi environment. To use it we wrap it inside another JAR that is an OSGi bundle named com.seeburger.osgi.e-iceblue.spire.pdf-11.8.3.SEE1-SNAPSHOT.jar (attached via link).
Here is a detailed description of how to reproduce the issue using Zulu JDK 21 and Apache Karaf on Windows:
1. Download the JDK - 21.0.8+9 Azul Zulu: 21.44.17 Windows x86 64-bit
2. Unpack the JDK in some directory – in my case it is C:\Projects\PDF_A_via_Spire\KARAF_TEST\zulu21.44.17-ca-jdk21.0.8-win_x64
3. Download Apache Karaf apache-karaf-4.4.8.tar.gz
4. Unpack Karaf in some directory – in my case it is C:\Projects\PDF_A_via_Spire\KARAF_TEST\apache-karaf-4.4.8
5. Place the attached files karaf-commands-1.14.8.jar and com.seeburger.osgi.e-iceblue.spire.pdf-11.8.3.SEE1-SNAPSHOT.jar in the deploy directory of Karaf (C:\Projects\PDF_A_via_Spire\KARAF_TEST\apache-karaf-4.4.8\deploy)
6. On a command line set the JAVA_HOME variable:
Code: Select all
C:\Projects\PDF_A_via_Spire\KARAF_TEST\apache-karaf-4.4.8\bin>set JAVA_HOME=C:\Projects\PDF_A_via_Spire\KARAF_TEST\zulu21.44.17-ca-jdk21.0.8-win_x64

7. Then start the Karaf OSGi environment from the command line:
Code: Select all
C:\Projects\PDF_A_via_Spire\KARAF_TEST\apache-karaf-4.4.8\bin>.\karaf.bat

8. Make sure the two JARs/bundles are properly activated:
Code: Select all
karaf@root()> bundle:list -s | grep -i see
53 │ Active │  80 │ 11.8.3.SEE1-SNAPSHOT │ com.seeburger.osgi.e-iceblue.spire.pdf
54 │ Active │  80 │ 1.14.8               │ com.seeburger.bic.common.karaf-commands

9. Run a command (created for tests only) to convert one PDF file to PDF/A (first parameter is source second is destination):
Code: Select all
karaf@root()> spire:convert-to-pdfa "C:\Projects\PDF_A_via_Spire\TestInputs_IV\wordpress-pdf-invoice-plugin-sample.pdf" "C:\Projects\PDF_A_via_Spire\outputs_local_test\out.pdf"

Make sure the source file and the destination directory of the two PDF exist.

The attachments to this post (in SpireTestAttachments.zip) are:
1. karaf-commands-1.14.8.jar – simple Karaf command to test Spire - spire:convert-to-pdfa
2. PDFConvertCommand.java – source code of the Karaf command (for a reference)
3. com.seeburger.osgi.e-iceblue.spire.pdf-11.8.3.SEE1-SNAPSHOT.jar – Spire.PDF JAR wrapped as OSGi bundle (link shared via mail)
4. wordpress-pdf-invoice-plugin-sample.pdf – example PDF to convert

The com.seeburger.osgi.e-iceblue.spire.pdf-11.8.3.SEE1-SNAPSHOT.jar seems to be too large to attach here so I am sharing it via public file sharing link (see mail).

The result you will see on the Karaf console is expected to be:
Code: Select all
C:\Projects\PDF_A_via_Spire\KARAF_TEST\apache-karaf-4.4.8\bin>set JAVA_HOME=C:\Projects\PDF_A_via_Spire\KARAF_TEST\zulu21.44.17-ca-jdk21.0.8-win_x64

C:\Projects\PDF_A_via_Spire\KARAF_TEST\apache-karaf-4.4.8\bin>.\karaf.bat
        __ __                  ____
       / //_/____ __________ _/ __/
      / ,<  / __ `/ ___/ __ `/ /_
     / /| |/ /_/ / /  / /_/ / __/
    /_/ |_|\__,_/_/   \__,_/_/

  Apache Karaf (4.4.8)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

karaf@root()> bundle:list -s | grep -i see
53 │ Active │  80 │ 11.8.3.SEE1-SNAPSHOT │ com.seeburger.osgi.e-iceblue.spire.pdf
54 │ Active │  80 │ 1.14.8               │ com.seeburger.bic.common.karaf-commands
karaf@root()>
karaf@root()>
karaf@root()> spire:convert-to-pdfa "C:\Projects\PDF_A_via_Spire\TestInputs_IV\wordpress-pdf-invoice-plugin-sample.pdf" "C:\Projects\PDF_A_via_Spire\outputs_local_test\out.pdf"
EVF7 > Start of conversion for file: C:\Projects\PDF_A_via_Spire\TestInputs_IV\wordpress-pdf-invoice-plugin-sample.pdf
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.seeburger.bic.common.karaf.PDFConvertCommand.execute(PDFConvertCommand.java:77)
        at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:88)
        at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
        at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
        at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
        at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
        at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "arg0" is null
        at com.spire.pdf.packages.sprmsv.spr┌℠(MemoryStream.java:424)
        at com.spire.pdf.packages.sprzov.spr┺⅜(Assembly.java:40)
        at com.spire.pdf.packages.sprpro.spr┴╿(Unknown Source)
        at com.spire.pdf.packages.spruuo.spr⅟╾(Unknown Source)
        at com.spire.pdf.packages.spruuo.spr†╿(Unknown Source)
        at com.spire.pdf.packages.sprwro.spr▁╿(Unknown Source)
        at com.spire.pdf.packages.sprfto.spr┛▃(Unknown Source)
        at com.spire.pdf.packages.sprfto.spr┺▃(Unknown Source)
        at com.spire.pdf.conversion.PdfStandardsConverter.spr⌮▃(Unknown Source)
        at com.spire.pdf.conversion.PdfStandardsConverter.toPdfA3B(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 15 more
CRITICAL_ERROR
karaf@root()>

seeburger
 
Posts: 5
Joined: Thu Sep 18, 2025 10:19 am

Thu Sep 25, 2025 1:11 pm

I have also tested with the very latest version of Spire - e-iceblue/spire.pdf/11.9.6/spire.pdf-11.9.6.jar but the issue still persists.

Code: Select all
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "arg0" is null
        at com.spire.pdf.packages.sprdxv.spr┭——(MemoryStream.java:424)
        at com.spire.pdf.packages.sprjlv.spr┻⅛(Assembly.java:40)
        at com.spire.pdf.packages.sprtqo.spr┄╿(Unknown Source)
        at com.spire.pdf.packages.sprdto.spr─╿(Unknown Source)
        at com.spire.pdf.packages.sprdto.spr∯╿(Unknown Source)
        at com.spire.pdf.packages.sprcto.spr╇╾(Unknown Source)
        at com.spire.pdf.packages.sprxxo.spr∫▄(Unknown Source)
        at com.spire.pdf.packages.sprxxo.spr┪▃(Unknown Source)
        at com.spire.pdf.conversion.PdfStandardsConverter.spr╓▃(Unknown Source)
        at com.spire.pdf.conversion.PdfStandardsConverter.toPdfA3B(Unknown Source)


It may help if Spire developers could at least give us a clue as to what is done in the code at
com.spire.pdf.packages.sprdxv.spr┭——(MemoryStream.java:424)

Is it possible that some resource was searched via the JVM system class loader but was not found i.e. is null etc. ?

seeburger
 
Posts: 5
Joined: Thu Sep 18, 2025 10:19 am

Fri Sep 26, 2025 10:20 am

Hello,

Thank you for your detailed information.
I can reproduce the issue based on the details you provided and have logged this issue into our tracking system under the ticket number SPIREPDF-7750. Our development colleagues are assisting in analyzing possible causes. Once there is any update, I will notify you immediately. Apologize for the inconvenience caused.
Sincerely,
Talia
E-iceblue support team
User avatar

talia.liu
 
Posts: 331
Joined: Mon Apr 14, 2025 3:33 am

Tue Oct 07, 2025 2:07 pm

We have found how to fix (or at least work around) the problem. It seems some resources are loaded by Spire using the Java thread context class-loader (TCCL). In an OSGi enviroment this class-loader may not have access to the Spire JAR/bundle. Explicitly setting the TCCL to the Spire bundle class-loader avoids the problem. No NullPointerException occurs and the process of PDF/A conversion completes successfully.

The above may or may not be the correct solution to the issue but it works at least in a Karaf OSGi environment. It is still a good idea for Spire developers to provide expert advice in this matter. The investigation priority of this problem may be lowered.

Best Regards,
Ivan Vaklinov
 
BG Business Integration Converter Group, Seeburger Corporation
SEEBURGER INFORMATIK EOOD, 16-A Dr G.M.Dimitrov blvd. Izgrev Distr Sofia, 1797 Bulgaria
SEEBURGER AG - Edisonstr.1 , D-75015 Bretten, Germany
[email protected]

seeburger
 
Posts: 5
Joined: Thu Sep 18, 2025 10:19 am

Wed Oct 08, 2025 1:49 am

Hi,

Thank you very much for sharing the solution to the class loading issue with Spire in the OSGi environment. Your feedback is highly valuable to us.

We have forwarded your findings to our development team for further analysis and resolution. We will work on a proper fix and keep you promptly informed once we have updates or a confirmed solution.

Thank you again for your support and understanding.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF