Monday, December 29, 2008

PDFBox Lucene java.lang.NoSuchMethodError

PDFBox version 0.7.3 is currently not compatible with the latest Lucene releases (for example Lucene v 2.4.0).

If you try to build an application using these two conflicting libraries you will most likely get an exception like:


One of the potential solution to solve the problem above is to recompile the PDFBox lib (you will need Ant installed on your machine).

If you download PDFBox and extract it in a $PDFBox dir of your choice, you will notice that in the sub-directory:

$PDFBox/external

Lucene v2.0.0 is used to build the library. Rename or delete both the lucene-core-2.0.0.jar and lucene-demos-2.0.0.jar files and copy in the directory the newer versions (for example lucene-core-2.4.0.jar and lucene-demos-2.4.0.jar).

Go to the top-level $PDFBox directory and simply run "ant" the project will be recompiled. A new library should be created (in my case a PDFBox-0.7.3-dev.jar library located in $PDFBox/lib was created).

Notice, in case you get another exception concerning org.fontbox.afm.AFMParser like in the screenshot below:


you will also need the additional fontbox library added to your project (for example in Netbeans add the library FontBox-0.1.0.jar to the libraries).

1 comments:

海舟 said...

Thank you very much !! I`m a student from China .This exception made me so sorrow last night and your passage let me finish it ~
Thank you very much !!And Thank you very much !!!!