Search code examples
javaluceneclassloader

Build lucene from sources: Codec does not exist


I've imported Lucene sources and built successfully. But when I'm trying to use any of Lucene classes, I get

A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene410' does not exist
The current classpath supports the following names: []

I tried to get path to classes by

String path = Lucene410Codec.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();

And got right path, so there is no problem with wrong jar-file.


Solution

  • The problem was that I've missed META-INF folder while imported project. I've manually added META-INF/services folder and it's contents - codecs files (which I took from lucene.core.jar) to sources and configured right build path.

    add something to resources in eclipse

    Now I can work with Lucene.