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()>
Login to view the files attached to this post.