Hi,
We're using Tika in the Apache Sling project and we're testing for
compatibility with Java 9.
One of the issues that came up is that tika-core has a dependency on
JAXB [1]. The javax.xml.bind packages are no longer part of the java.se
module, and therefore not available by default on the module path. The
issue can be triggered with a simple invocation of tika-app on Java 9:
$ java -jar tika-app-1.16.jar --config=tika-config.xml settings.xml
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.apache.tika.parser.ParseContext (file:/home/robert/Downloads/tika-
app-1.16.jar) to method
com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpans
ionLimit(int)
WARNING: Please consider reporting this to the maintainers of
org.apache.tika.parser.ParseContext
WARNING: Use --illegal-access=warn to enable warnings of further
illegal reflective access operations
WARNING: All illegal access operations will be denied in a future
release
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/xml/bind/JAXBException
at
org.apache.tika.config.TikaConfig.<init>(TikaConfig.java:178)
at
org.apache.tika.config.TikaConfig.<init>(TikaConfig.java:164)
at
org.apache.tika.config.TikaConfig.<init>(TikaConfig.java:139)
at
org.apache.tika.config.TikaConfig.<init>(TikaConfig.java:135)
at org.apache.tika.cli.TikaCLI.configure(TikaCLI.java:680)
at org.apache.tika.cli.TikaCLI.process(TikaCLI.java:467)
at org.apache.tika.cli.TikaCLI.main(TikaCLI.java:145)
Caused by: java.lang.ClassNotFoundException:
javax.xml.bind.JAXBException
at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClass
Loader.java:582)
at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Cla
ssLoaders.java:185)
at
java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 7 more
One workaround is to use the --add-modules CLI switch, e.g.
$ java --add-modules java.se.ee -jar tika-app-1.16.jar --config=tika-
config.xml settings.xml
Looking at tika-core, I see that only the org.apache.tika.config
package requires JAXB classes:
$ jdeps tika-core-1.14.jar | grep java.xml.bind
org.apache.tika.config ->
javax.xml.bind java.xml.bind
org.apache.tika.config ->
javax.xml.bind.annotation java.xml.bind
org.apache.tika.config ->
javax.xml.bind.helpers java.xml.bind
To wrap up:
Is there interest in making Tika work on Java 9 without the need to use
the '--add-modules' switch? That would entail just removing the
java.xml.bind dependencies ; for tika-core and tika-parsers all the
dependencies are contained in java.se .
Given that there is interest, what would be the preferred solution and
the plans for a next release? I might be able to provide a patch if
it's not too invasive.
Thanks,
Robert
(Please keep me in CC, I'm not subscribed to the list)
[1]: https://issues.apache.org/jira/browse/SLING-7108