[
https://issues.apache.org/jira/browse/TIKA-4934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18119665#comment-18119665
]
ASF GitHub Bot commented on TIKA-4934:
--------------------------------------
ppkarwasz opened a new pull request, #3260:
URL: https://github.com/apache/tika/pull/3260
[TIKA-4934](https://issues.apache.org/jira/browse/TIKA-4934)
`tika-bundle-standard` is meant to embed only the dependencies that aren't
OSGi bundles themselves, but it also embedded many that ship proper OSGi
manifests. This PR stops embedding them. It also fixes PDF parsing in OSGi,
which failed because `pdfbox-io` was never embedded:
```
java.lang.NoClassDefFoundError: org/apache/pdfbox/io/RandomAccessReadBuffer
Caused by: java.lang.ClassNotFoundException:
org.apache.pdfbox.io.RandomAccessReadBuffer not found by
org.apache.tika.bundle-standard
```
### No longer embedded (must be deployed as separate bundles)
commons-io, commons-codec, commons-collections4, commons-compress,
commons-csv, commons-exec, commons-lang3, commons-math3, xz, pdfbox, fontbox,
pdfbox-io, commons-logging (1.4+; `jcl-over-slf4j` only exports 1.2),
bcprov/bcpkix/bcutil/bcjmail, jsoup, asm, xmpcore, dd-plist.
### Still embedded, although they are bundles
- `apache-mime4j-core`/`-dom`: they import
`org.apache.commons.io;version="[1.4,2)"`, which commons-io 2.x doesn't satisfy.
- `rome`: it requires `org.jdom2`, which isn't a bundle.
- `jackcess`/`jackcess-encrypt`: jackcess uses
`org.apache.poi.poifs.filesystem` for OLE attachments, and POI only exists
inside the bundle.
### Tests
`BundleIT` now:
- installs every jar that `test-bundles.xml` copies to `target/test-bundles`;
- asserts that all bundles are active;
- checks that classes from each external dependency load through the bundle
that uses it. Every import of `tika-bundle-standard` is optional, so without
this check a missing bundle wouldn't fail the test;
- parses a PDF inside the container. This test fails on current `main` with
the error above.
The PDF test calls `PDFParser` directly. Parsing through the registered
`Parser` service overflows the stack: `TikaActivator` passes the
`DefaultParser` service registered by `BundleActivator` back into
`ServiceLoader` as a dynamic provider, and `DefaultParser.getParsers()` then
includes itself. That's a separate issue.
### Compatibility
OSGi deployments of `tika-bundle-standard` need the bundles listed above.
`CHANGES.txt` only has the in-progress 4.1.0 section, so I didn't add an entry.
I'm happy to add one wherever you prefer.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
> tika-bundle-standard: do not embed dependencies that are OSGi bundles
> ---------------------------------------------------------------------
>
> Key: TIKA-4934
> URL: https://issues.apache.org/jira/browse/TIKA-4934
> Project: Tika
> Issue Type: Improvement
> Reporter: Piotr Karwasz
> Priority: Minor
>
> The {{tika-bundle-standard}} OSGi bundle is described as containing "the
> tika-parsers-standard component and all its upstream dependencies that aren't
> OSGi bundles by themselves," but its {{Embed-Dependency}} list also embeds
> many dependencies that ship proper OSGi manifests. As a result:
> * these libraries are duplicated inside the bundle instead of being shared
> with other bundles in the container, and they can't be updated independently;
> * {{commons-io}} is both embedded and installed as a separate bundle;
> * {{pdfbox-io}} is not embedded at all, although {{pdfbox}} and {{fontbox}}
> require {{org.apache.pdfbox.io}}. Since every import of
> {{tika-bundle-standard}} is optional, the bundle resolves anyway and PDF
> parsing fails at runtime with {{NoClassDefFoundError}}.
> h3. Proposed change
> Stop embedding the following dependencies; they must be deployed as separate
> bundles alongside {{tika-core}} and {{tika-bundle-standard}}:
> * {{commons-io:commons-io}}
> * {{commons-codec:commons-codec}}
> * {{commons-logging:commons-logging}} (1.4+, required by pdfbox;
> {{jcl-over-slf4j}} only exports version 1.2)
> * {{org.apache.commons:commons-collections4}}
> * {{org.apache.commons:commons-compress}}
> * {{org.apache.commons:commons-csv}}
> * {{org.apache.commons:commons-exec}}
> * {{org.apache.commons:commons-lang3}}
> * {{org.apache.commons:commons-math3}}
> * {{org.apache.pdfbox:pdfbox}}
> * {{org.apache.pdfbox:pdfbox-io}}
> * {{org.apache.pdfbox:fontbox}}
> * {{org.bouncycastle:bcprov-jdk18on}}, {{bcpkix-jdk18on}},
> {{bcutil-jdk18on}}, {{bcjmail-jdk18on}}
> * {{org.jsoup:jsoup}}
> * {{org.ow2.asm:asm}}
> * {{org.tukaani:xz}}
> * {{com.adobe.xmp:xmpcore}}
> * {{com.googlecode.plist:dd-plist}}
> The following are OSGi bundles but stay embedded because they cannot be
> resolved as standalone bundles:
> * {{apache-mime4j-core}} / {{apache-mime4j-dom}}: import
> {{org.apache.commons.io;version="[1.4,2)"}}, which commons-io 2.x does not
> satisfy;
> * {{rome}}: requires {{org.jdom2}}, which is not an OSGi bundle;
> * {{jackcess}} / {{jackcess-encrypt}} (fragment): {{jackcess}} uses
> {{org.apache.poi.poifs.filesystem}} for OLE attachments, and POI is only
> available inside {{tika-bundle-standard}}.
> h3. Tests
> {{BundleIT}} now installs every jar in {{target/test-bundles}} (populated by
> {{test-bundles.xml}}), asserts that all bundles are active, and checks that
> classes from each external dependency can be loaded through
> {{tika-bundle-standard}}, since optional imports would otherwise hide a
> missing bundle.
> h3. Compatibility
> OSGi users of {{tika-bundle-standard}} must deploy the bundles listed above.
> The list should be mentioned in {{CHANGES.txt}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)