pcorless / icepdf

PDF Rendering and Viewing API in Java
Apache License 2.0
84 stars 21 forks source link

ICE-Pdf viewer can't be used with Java modular project! #353

Closed ctoabidmaqbool1 closed 6 months ago

ctoabidmaqbool1 commented 7 months ago

I am trying to convert my project to modular e.g. with module-info.java but there is an issue when i try to execute jLink task!

error: duplicate module on application module path
  module in org.bouncycastle.provider

Now com.github.pcorless.icepdf:icepdf-viewer:7.2.0 depedencies:

+--- com.github.pcorless.icepdf:icepdf-viewer:7.2.0
|    \--- com.github.pcorless.icepdf:icepdf-core:7.2.0
|         +--- org.bouncycastle:bcprov-ext-jdk18on:1.76
|         +--- org.bouncycastle:bcpkix-jdk18on:1.76
|         |    +--- org.bouncycastle:bcprov-jdk18on:1.76
|         |    \--- org.bouncycastle:bcutil-jdk18on:1.76
|         |         \--- org.bouncycastle:bcprov-jdk18on:1.76
|         +--- com.twelvemonkeys.imageio:imageio-tiff:3.9.4
|         |    +--- com.twelvemonkeys.imageio:imageio-core:3.9.4
|         |    |    +--- com.twelvemonkeys.common:common-lang:3.9.4
|         |    |    +--- com.twelvemonkeys.common:common-io:3.9.4
|         |    |    |    \--- com.twelvemonkeys.common:common-lang:3.9.4
|         |    |    \--- com.twelvemonkeys.common:common-image:3.9.4
|         |    |         +--- com.twelvemonkeys.common:common-lang:3.9.4
|         |    |         \--- com.twelvemonkeys.common:common-io:3.9.4 (*)
|         |    +--- com.twelvemonkeys.imageio:imageio-metadata:3.9.4
|         |    |    +--- com.twelvemonkeys.imageio:imageio-core:3.9.4 (*)
|         |    |    +--- com.twelvemonkeys.common:common-lang:3.9.4
|         |    |    +--- com.twelvemonkeys.common:common-io:3.9.4 (*)
|         |    |    \--- com.twelvemonkeys.common:common-image:3.9.4 (*)
|         |    +--- com.twelvemonkeys.common:common-lang:3.9.4
|         |    +--- com.twelvemonkeys.common:common-io:3.9.4 (*)
|         |    \--- com.twelvemonkeys.common:common-image:3.9.4 (*)
|         +--- org.apache.pdfbox:fontbox:2.0.27 (*)
|         +--- commons-logging:commons-logging:1.2
|         \--- org.apache.pdfbox:jbig2-imageio:3.0.4

The libs bcprov-ext-jdk18on and bcprov-jdk18on have same module e.g. org.bouncycastle.provider how to solve the prblem. e.g. which lib should be excluded?

ctoabidmaqbool1 commented 7 months ago

Moreover, ICEPdf Viewer libray is not modular one e.g. having module-info.java, Java pick auto modular name.

ctoabidmaqbool1 commented 7 months ago

Sample project : https://github.com/ctoabidmaqbool1/ICEPDF-Viewer-Modular-Test

Also it's not working:

implementation('com.github.pcorless.icepdf:icepdf-core:7.2.0') {
    exclude group: 'org.bouncycastle', module: 'bcprov-ext-jdk18on'
}
implementation 'com.github.pcorless.icepdf:icepdf-viewer:7.2.0'
ctoabidmaqbool1 commented 7 months ago
 implementation('com.github.pcorless.icepdf:icepdf-core:7.2.0') {
        exclude module: 'bcprov-ext-jdk18on'
    }
    implementation('com.github.pcorless.icepdf:icepdf-viewer:7.2.0') {
        exclude module: 'bcprov-ext-jdk18on'
    }

@pcorless This somehow solve the issue, But I am not sure if I can exclude bcprov-ext-jdk18on without any major issue?

pcorless commented 7 months ago

Pretty sure I have that fixed on the head/trunk branch but will double check. You can keep bcprov-ext-jdk18on and exclude bcprov-jdk18on.

pcorless commented 7 months ago

I'll take a look at the module, that's been on my todo list for quite some time.

ctoabidmaqbool commented 7 months ago

Another issue I am facing is:

Providers:
  com.ctc.wstx provides com.ctc.wstx.shaded.msv.org_isorelax.verifier.VerifierFactoryLoader not used by any observable module
  com.ctc.wstx provides com.ctc.wstx.shaded.msv.relaxng_datatype.DatatypeLibraryFactory not used by any observable module
  com.fasterxml.jackson.dataformat.xml provides com.fasterxml.jackson.core.JsonFactory not used by any observable module
  com.fasterxml.jackson.databind provides com.fasterxml.jackson.core.ObjectCodec used by com.fasterxml.jackson.core
  com.fasterxml.jackson.dataformat.xml provides com.fasterxml.jackson.core.ObjectCodec used by com.fasterxml.jackson.core
  com.fasterxml.jackson.datatype.jsr310 provides com.fasterxml.jackson.databind.Module used by com.fasterxml.jackson.databind
  com.my.app.merged.module provides io.jsonwebtoken.CompressionCodec not used by any observable module
  com.my.app.merged.module provides io.jsonwebtoken.io.Deserializer not used by any observable module
  com.my.app.merged.module provides io.jsonwebtoken.io.Serializer not used by any observable module
  java.desktop provides java.net.ContentHandlerFactory used by java.base
  java.base provides java.nio.file.spi.FileSystemProvider used by java.base
  java.naming provides java.security.Provider used by java.base
  java.security.jgss provides java.security.Provider used by java.base
  java.security.sasl provides java.security.Provider used by java.base
  java.xml.crypto provides java.security.Provider used by java.base
  org.bouncycastle.provider provides java.security.Provider used by java.base
  com.my.app.merged.module provides java.sql.Driver used by java.sql
  org.hsqldb provides java.sql.Driver used by java.sql
  java.base provides java.util.random.RandomGenerator used by java.base
  com.my.app.merged.module provides javax.imageio.spi.ImageInputStreamSpi used by java.desktop
  com.my.app.merged.module provides javax.imageio.spi.ImageReaderSpi used by java.desktop
  com.my.app.merged.module provides javax.imageio.spi.ImageWriterSpi used by java.desktop
  java.desktop provides javax.print.PrintServiceLookup used by java.desktop
  java.desktop provides javax.print.StreamPrintServiceFactory used by java.desktop
  java.management provides javax.security.auth.spi.LoginModule used by java.base
  java.desktop provides javax.sound.midi.spi.MidiDeviceProvider used by java.desktop
  java.desktop provides javax.sound.midi.spi.MidiFileReader used by java.desktop
  java.desktop provides javax.sound.midi.spi.MidiFileWriter used by java.desktop
  java.desktop provides javax.sound.midi.spi.SoundbankReader used by java.desktop
  java.desktop provides javax.sound.sampled.spi.AudioFileReader used by java.desktop
  java.desktop provides javax.sound.sampled.spi.AudioFileWriter used by java.desktop
  java.desktop provides javax.sound.sampled.spi.FormatConversionProvider used by java.desktop
  java.desktop provides javax.sound.sampled.spi.MixerProvider used by java.desktop
  com.ctc.wstx provides javax.xml.stream.XMLEventFactory used by java.xml
  com.ctc.wstx provides javax.xml.stream.XMLInputFactory used by java.xml
  com.ctc.wstx provides javax.xml.stream.XMLOutputFactory used by java.xml
  java.logging provides jdk.internal.logger.DefaultLoggerFinder used by java.base
  com.my.app.merged.module provides org.apache.batik.script.InterpreterFactory not used by any observable module
  com.ctc.wstx provides org.codehaus.stax2.validation.XMLValidationSchemaFactory$dtd not used by any observable module
  com.ctc.wstx provides org.codehaus.stax2.validation.XMLValidationSchemaFactory$relaxng not used by any observable module
  com.ctc.wstx provides org.codehaus.stax2.validation.XMLValidationSchemaFactory$w3c not used by any observable module
  java.desktop provides sun.datatransfer.DesktopDatatransferService used by java.datatransfer
  jdk.management provides sun.management.spi.PlatformMBeanProvider used by java.management
  jdk.unsupported.desktop provides sun.swing.InteropProvider used by java.desktop
Error: signed modular JAR D:\my-project\build\jlinkbase\jlinkjars\bcpkix-jdk18on-1.76.jar is currently not supported, use --ignore-signing-information to suppress error

and I have tried --ignore-signing-information that is too not working noir:

implementation('com.github.pcorless.icepdf:icepdf-core:7.2.0') {
        exclude module: 'bcprov-jdk18on'
        exclude module: 'bcpkix-jdk18on'
    }
    implementation('com.github.pcorless.icepdf:icepdf-viewer:7.2.0') {
        exclude module: 'bcprov-jdk18on'
        exclude module: 'bcpkix-jdk18on'
    }
ctoabidmaqbool1 commented 7 months ago

Anyway I have to exclude both bcprov-ext-jdk18on and bcpkix-jdk18on to solve my problem!

implementation('com.github.pcorless.icepdf:icepdf-core:7.2.0') {
    exclude module: 'bcprov-ext-jdk18on'
    exclude module: 'bcpkix-jdk18on'
}
implementation('com.github.pcorless.icepdf:icepdf-viewer:7.2.0') {
    exclude module: 'bcprov-ext-jdk18on'
    exclude module: 'bcpkix-jdk18on'
}
pcorless commented 7 months ago

Still working on testing this for some reflective loading corners cases but the above branch should provide basic module support and address some of the dependency issue you saw. Let me know how it goes.

pcorless commented 6 months ago

Can run the viewer RI with java --module-path ./libs/ --module org.icepdf.ri.viewer