2
votes

Edit: This question is solved. For some reason there indeed was another version of the Lucene files in the plugins directory of Eclipse.

I'm trying to use Lucene in an Eclipse plugin. It's methods are supposed to be called from another plugin.

It works great as long as I run the project as a Java Application. But when I try to call a method from the other plugin, I get the following error:

java.lang.NoSuchMethodError: org.apache.lucene.store.FSDirectory.open(Ljava/nio/file/Path;)Lorg/apache/lucene/store/FSDirectory;

Of course the method does indeed exist as it runs perfectly fine as a Java Application. Therefore I guess I have to do something plugin-specific to make it work.

I added the necessary Lucene-jars (lucene-analyzers-common-5.3.1 and lucene-core-5.3.1) to the dependencies of my plugin. I also added org.apache.lucene.store to the Exported Packages of my plugin (as suggested by Eclipse so the plugin which calls the method can catch the LockObtainFailedException). That's everything I've done regarding Lucene.

Can someone tell me what I forgot / don't know about? (If it's not obvious, I am completly new to Eclipse plugins)

Edit: I've also tried to add the jars directly to the plugin which is calling the Lucene-method (by adding the paths to Bundle-ClassPath in the manifest). Didn't change anything.

I've also read that such a problem may occur due to another version of Lucene being somewhere in my classpath. I made sure that's not the case.

1
check if the jar has downloaded completelyAbdullah Al Noman
@AbdullahAlNoman as stated in the Question, there are no problems with the jar when running the project as a Java Application (and not a Eclipse Application), so I doubt that's possibly the problem.Jdv
Where have you put these jars? Everything an Eclipse plugin uses must be in a plugin, just referencing jars in the Classpath won't work properly. Eclipse does come with some older Lucene plugins, you might be referencing those. Show us the MANIFEST.MF and build.properties for the plugin containing the Lucene jars.greg-449
I added an Edit to the beginning of my post. I've found the problem. Exactly as you say, it were the older Lucene jars which come with Eclipse. I figured I should leave the post with the solution so someone with the same problem could read it.Jdv
Write up your solution as an Answer rather than editing the question. It is perfectly acceptable to answer your own question.greg-449

1 Answers

1
votes

For some reason there indeed was another (older) version of the Lucene files in the plugins directory of Eclipse. These were the problem. I deleted them and removed the version tag in the manifest.