lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: Having some trouble running tests with custom codec
Date Mon, 12 Oct 2015 06:47:21 GMT

adding the codec JAR to the ANT classpath does not help, as it is not part of the test classpath:

> Running *ant -Dtestcase=TestSegmentTermDocs -Dtests.codec=HelloCodec
> -lib
> /path/to/hello-1.0.jar* test gives me the following error:

* -lib cannot work as it just adds your JAR to ant's own classpath, not the one of the test
* -Dtests.codec must be the name your own codec is returning in getName(). This is not the
class name.

To make this work, you have to pass your codec to test's classpath. This can only be done
with hacking Lucene's build.xml files, because the test classpath is isolated from anything
outside, especially ANT's classpath.
In addition, your codec must be a full-featured codec with own name, returned by getName().
This name should not contain the String "Codec", just the plain name (like "Lucene53", "Hello",
"FooBar123"). This name must be passed to "-Dtests.codec".


Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen

> -----Original Message-----
> From: Sigbjørn Lund Olsen []
> Sent: Friday, October 09, 2015 4:08 PM
> To:
> Subject: Having some trouble running tests with custom codec
> As part of my master's thesis I am planning on implementing a custom
> Lucene codec for compression experiments.
> To get started with my prototype, I've tried following the instructions here
> (but using the more recent Lucene 5.3.1):
> lucene-codec/
> However, I am having some trouble getting the codec to load when running
> Lucene tests.
> I've uploaded a minimal project at
> Running *mvn package* generates a jar with a file
> *META-INF/services/org.apache.lucene.codecs.Codec* containing a single
> line:
> edu.ntnu.sigbjornlo.codecs.HelloCodec
> ...which is where the codec class resides at. It's just a FilterCodec subclass
> that does nothing extra.
> Running *ant -Dtestcase=TestSegmentTermDocs -Dtests.codec=HelloCodec
> -lib
> /path/to/hello-1.0.jar* test gives me the following error:
> java.lang.IllegalArgumentException: An SPI class of type
> org.apache.lucene.codecs.Codec with name 'HelloCodec' does not exist. You
> need to add the corresponding JAR file supporting this SPI to your classpath.
> The current classpath supports the following names: [SimpleText, Asserting,
> CheapBastard, FastCompressingStoredFields,
> FastDecompressionCompressingStoredFields,
> HighCompressionCompressingStoredFields,
> DummyCompressingStoredFields, Lucene53]
> What might I be doing wrong here? Is there any way to make Lucene's SPI
> loader log what it's trying and/or failing to load, and why?
> (Be adviced: I have also asked this question on StackOverflow:
> use-a-custom-codec-from-external-jar
> )
> Sincerely,
> Sigbjørn Lund Olsen

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message