Skip to content

camel-tika: tika:parse returns empty content in OSGi (ServiceLoader parser discovery not mediated) #727

Description

@jbonofre

Problem

In Karaf, the tika:parse operation returns empty content regardless of input, with no exception and no warning. The camel-tika feature installs and the route runs end-to-end, but nothing is ever extracted from the document.

Root cause

Camel's TikaProducer builds a new AutoDetectParser(TikaConfig). AutoDetectParser discovers org.apache.tika.parser.Parser implementations through the JDK ServiceLoader (META-INF/services/org.apache.tika.parser.Parser), which does not cross OSGi bundle boundaries. The parser implementations live in separate bundles (tika-parser-html-module, tika-parser-text-module, …) that the tika-core bundle's classloader cannot see, so AutoDetectParser finds no parser and falls back to EmptyParser → empty output.

Verified in a Pax Exam container: the route logs

Will parse: <html>...The quick brown fox...</html>
Parsed:

Adding the Karaf spifly feature to camel-tika alone does not fix it — the Tika parser-module bundles also need SPI-Provider wiring for SPIFly to register them.

Scope

This is a Karaf-specific OSGi integration gap in the camel-tika feature, separate from #713 (which only fixed the missing juniversalchardet transitive bundle so the parser modules resolve). The itest added in #716 deliberately does not assert on extracted content for this reason.

Possible directions

  • Wrap the tika-parser-* module bundles with the appropriate SPI-Provider / Require-Capability osgi.serviceloader clauses and add spifly to the feature so AutoDetectParser's ServiceLoader.load is mediated by SPIFly.
  • Or provide an OSGi-aware TikaConfig/parser wiring in camel-core-osgi / the camel-tika packaging.

Once resolved, the camel-tika itest can be tightened to assert on the extracted text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions