Search code examples
mavenjavacapache-tika

Apache Tika compile error


I'm trying to follow what would appear to be very simple compilation instructions for Apache TikaJAXRS. I'm running on Windows 8.1 64bit.

  1. Download the latest stable source from the Apache Tika download page or retrieve the latest code from Github,
  2. Build source using Maven,
  3. Run the Apache Tika JAXRS server.

OK. I've done step 1, but am stumbling on step 2. Obviously there's some un-written pre-requisites here, so I've tried to address them as follows:

  • Installed Java SDK 8u25
  • Set JAVA_HOME variable to C:\Program Files\Java\jdk1.8.0_25
  • Set CLASSPATH variable to .
  • Added JDK BIN directory to PATH variable: C:\Program Files\Java\jdk1.8.0_25\bin
  • Added Maven BIN directory to PATH variable: C:\apache-maven-3.2.5\bin

Then from the tika-1.7 directory (content of the zip for the src download) I run mvn install. Compile progresses happily for several minutes before spitting the error output pasted below, at which point the compile appears to freeze.

The issue looks like it might be this one - https://issues.apache.org/jira/browse/TIKA-1276 There's some discussion there about re-creating the bundle and modifying files within to get past the issue, but I frankly find it bizarre that I'd have to jump through such hoops just to get a working copy of Tika - there is no binary distribution provided!

What do I need to do to get past this compile issue?

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.apache.tika.bundle.BundleIT
[main] INFO org.ops4j.pax.exam.spi.DefaultExamSystem - Pax Exam System (Version: 2.2.0) created.
Jan 19, 2015 11:48:40 AM org.ops4j.pax.url.mvn.internal.AetherBasedResolver resolve
INFO: Resolved (org.junit:com.springsource.org.junit:jar:4.4.0) as C:\Users\Jason\.m2\repository\org\junit\com.springsource.org.junit\4.4.0\com.springsource.org.junit-4.4.0.jar
ERROR: Bundle org.ops4j.pax.exam.rbc [1] Error starting link:classpath:META-INF/links/org.ops4j.pax.exam.rbc.link (org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.exam.rbc [1].)
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.ops4j.pax.exam.rbc.internal.Activator.<clinit>(Activator.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at java.lang.Class.newInstance(Class.java:438)
    at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4169)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1972)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory not found by org.ops4j.pax.exam.rbc [1]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 12 more
ERROR: Bundle org.ops4j.pax.exam.extender.service [2] Error starting link:classpath:META-INF/links/org.ops4j.pax.extender.service.link (org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.exam.extender.service [2]: Unable to resolve 2.0: missing requirement [2.0] osgi.wiring.package; (&(osgi.wiring.package=org.slf4j)(version>=1.6.0)(!(version>=2.0.0))) [caused by: Unable to resolve 4.0: missing requirement [4.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.parsers)])
org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.exam.extender.service [2]: Unable to resolve 2.0: missing requirement [2.0] osgi.wiring.package; (&(osgi.wiring.package=org.slf4j)(version>=1.6.0)(!(version>=2.0.0))) [caused by: Unable to resolve 4.0: missing requirement [4.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.parsers)]
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3818)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
    at java.lang.Thread.run(Thread.java:745)
ERROR: Bundle org.ops4j.pax.logging.pax-logging-api [4] Error starting link:classpath:META-INF/links/org.ops4j.pax.logging.api.link (org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.logging.pax-logging-api [4]: Unable to resolve 4.0: missing requirement [4.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.parsers))
org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.logging.pax-logging-api [4]: Unable to resolve 4.0: missing requirement [4.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.parsers)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3818)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
    at java.lang.Thread.run(Thread.java:745)
ERROR: Bundle org.apache.tika.core [6] Error starting file:/C:/Users/Jason/Desktop/FullText/Tika/tika-1.7/tika-bundle/target/test-bundles/tika-core.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.tika.core [6]: Unable to resolve 6.0: missing requirement [6.0] osgi.wiring.package; (osgi.wiring.package=javax.crypto))
org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.tika.core [6]: Unable to resolve 6.0: missing requirement [6.0] osgi.wiring.package; (osgi.wiring.package=javax.crypto)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3818)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
    at java.lang.Thread.run(Thread.java:745)
ERROR: Bundle org.apache.tika.bundle [7] Error starting file:/C:/Users/Jason/Desktop/FullText/Tika/tika-1.7/tika-bundle/target/test-bundles/tika-bundle.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.tika.bundle [7]: Unable to resolve 7.0: missing requirement [7.0] osgi.wiring.package; (osgi.wiring.package=javax.crypto))
org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.tika.bundle [7]: Unable to resolve 7.0: missing requirement [7.0] osgi.wiring.package; (osgi.wiring.package=javax.crypto)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3818)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
    at java.lang.Thread.run(Thread.java:745)

Solution

  • Promoting a comment to an answer...

    I'm not sure why your build is failing on that test, as it passes for me and for the automated build/test system. However... You probably don't want to be doing any of that!

    If you go to the Apache Tika download page, you will see a link to download the latest stable Tika Server runnable jar. Follow that link, pick your favourite mirror, download, verify the checksum and run. Simples!

    If you really do need to build the Tika Server from source (eg if you're going to be making changes to it), you can either skip the unit tests by running mvn install -DskipTests which will do the build with no tests, or you can edit pom.xml in the root of your source checkout and comment out the line <module>tika-bundle</module> to exclude the whole bundle section (tests and all) from your build. If you only want to use the Tika Server, then you don't need the OSGi bundle so can safely skip it