You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tika.apache.org by Robert Munteanu <ro...@apache.org> on 2017/09/14 14:12:21 UTC
Java 9 and JAXB dependency in tika-core
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
Re: Java 9 and JAXB dependency in tika-core
Posted by Robert Munteanu <ro...@apache.org>.
On Thu, 2017-09-14 at 17:22 +0300, Robert Munteanu wrote:
> > If you can think of a way to re-do the XML parsing in the Tika
> > Config
> > classes, such that they still work on Java 7+, but also work OOTB
> > on
> > Java
> > 9, we'd love a patch!
>
> I'll take a look, let's see if I can whip something up.
See https://issues.apache.org/jira/browse/TIKA-2466, with an attached
patch.
Thanks,
Robert
Re: Java 9 and JAXB dependency in tika-core
Posted by Robert Munteanu <ro...@apache.org>.
On Thu, 2017-09-14 at 15:19 +0100, Nick Burch wrote:
> On Thu, 14 Sep 2017, Robert Munteanu wrote:
> > 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
>
> Is there a recommended way to replace JAXB that still works on older
> versions of Java?
Well, it still works provided that you either add a CLI switch or make
tika a proper Java 9 module. But IMO it's simpler to just stop using
JAXB and make Tika work in all scenarios.
>
> > 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.
>
> If you can think of a way to re-do the XML parsing in the Tika
> Config
> classes, such that they still work on Java 7+, but also work OOTB on
> Java
> 9, we'd love a patch!
I'll take a look, let's see if I can whip something up.
>
> If not, if you could find some guideance online for how to migrate
> JAXB-using code to work with both Java 9 and 7+, we can take a look
> at
> some point
Thanks,
Robert
Re: Java 9 and JAXB dependency in tika-core
Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 14 Sep 2017, Robert Munteanu wrote:
> 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
Is there a recommended way to replace JAXB that still works on older
versions of Java?
> 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.
If you can think of a way to re-do the XML parsing in the Tika Config
classes, such that they still work on Java 7+, but also work OOTB on Java
9, we'd love a patch!
If not, if you could find some guideance online for how to migrate
JAXB-using code to work with both Java 9 and 7+, we can take a look at
some point
Thanks
Nick