java.lang.NoClassDefFoundError: Could not initiali

2019-08-23 12:40发布

问题:

I am using Apache Tika( tika-app 1.17) in wildfly modules. While I start extracting PDF it always throws the error:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.pdfbox.pdmodel.font.PDFont

For other file extensions it works fine. Things I have tried out dependencies in apache-tika module.xml to PDFbox Explicitly loaded org.apache.pdfbox from standalone.xml

I have also tried with the below structure app1.war->(WEB-INF)lib-->app.jar->lib-->tika-app-1.17.jar

I have also jboss-deployment-structure.xml where

    <dependencies>
      <module name="com.company.tika" />         
    </dependencies>

is mentioned as a module dependency. In MANIFEST.MF of the jar also, I have dependency to com.company.tika

Nothing seems to work.

Any suggestions or help would be thankful.

Thanks in Advance

Dwai

回答1:

I could resolve the issue. The problem was the minor version of pdfbox, fontbox and jempbox were not the same. Hence the PDFFont was not initialized, because internally it needs to load the classes of fontbox also and probably there was a mismatch in the version id of the classes



回答2:

I had similar problem. Under linux i just install missing library pdfbox by:

apt-get install libpdfbox-java
and restart solr server

After this modification i need to change solr start parameter in ./bin/solr from

SOLR_JAVA_STACK_SIZE='-Xss256kb'

to

SOLR_JAVA_STACK_SIZE='-Xss256M'

because i had error

java.lang.StackOverflowErrorjava.lang.RuntimeException: java.lang.StackOverflowError

of course i restart solr server again.

I hope, it help you reolve this problem.