Hi - i've created a small Maven project with just a custom Lucene 4.3 codec. It 
is a basic MyCodec extends FilterCodec implementation, disabling compression. I 
have added the FQCN to the 
src/main/resources/META-INF/services/org.apache.lucene.codecs.Codec. I have 
checked the jar itself to see if the file is actually there, it is. However, i 
cannot load the codec, although the jar is actually loaded. When configuring it 
in solrconfig.xml as CodecFactory, i get 

org.apache.solr.common.SolrException: class org.example.MyCodec
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:822)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:618)
        at 
org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:949)
        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:984)
        at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:597)
        at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:592)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: class org.example.MyCodec
        at java.lang.Class.asSubclass(Class.java:3397)
        at 
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:448)
        at 
org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:486)
        at 
org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:482)
        at org.apache.solr.core.SolrCore.initCodec(SolrCore.java:847)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:734)
        ... 11 more
3144 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer  – 
null:org.apache.solr.common.SolrException: Unable to create core: collection1
        at 
org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:1450)
        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:993)
        at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:597)
        at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:592)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.solr.common.SolrException: class org.example.MyCodec
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:822)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:618)
        at 
org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:949)
        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:984)
        ... 8 more
Caused by: java.lang.ClassCastException: class org.example.MyCodec
        at java.lang.Class.asSubclass(Class.java:3397)
        at 
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:448)
        at 
org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:486)
        at 
org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:482)
        at org.apache.solr.core.SolrCore.initCodec(SolrCore.java:847)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:734)
        ... 11 more

I also cannot load the codec as postingsFormat="MyCodec" on a field type 
definition. Then i get a 

Caused by: java.lang.IllegalArgumentException: A SPI class of type 
org.apache.lucene.codecs.PostingsFormat with name 'MyCodec' does not exist. You 
need to add the corresponding JAR file supporting this SPI to your 
classpath.The current classpath supports the following names: [Lucene40, 
Lucene41, Pulsing41, SimpleText, Memory, BloomFilter, Direct]
        at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:111)
        at 
org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:100)
        at 
org.apache.solr.core.SchemaCodecFactory$1.getPostingsFormatForField(SchemaCodecFactory.java:55)
        at 
org.apache.lucene.codecs.lucene42.Lucene42Codec$1.getPostingsFormatForField(Lucene42Codec.java:59)
        at 
org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsWriter.addField(PerFieldPostingsFormat.java:102)
        at 
org.apache.lucene.index.FreqProxTermsWriterPerField.flush(FreqProxTermsWriterPerField.java:336)
        at 
org.apache.lucene.index.FreqProxTermsWriter.flush(FreqProxTermsWriter.java:85)
        at org.apache.lucene.index.TermsHash.flush(TermsHash.java:116)
        at org.apache.lucene.index.DocInverter.flush(DocInverter.java:53)
        at 
org.apache.lucene.index.DocFieldProcessor.flush(DocFieldProcessor.java:81)
        at 
org.apache.lucene.index.DocumentsWriterPerThread.flush(DocumentsWriterPerThread.java:493)
        at 
org.apache.lucene.index.DocumentsWriter.doFlush(DocumentsWriter.java:422)
        at 
org.apache.lucene.index.DocumentsWriter.flushAllThreads(DocumentsWriter.java:559)
        at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:365)
        at 
org.apache.lucene.index.StandardDirectoryReader.doOpenIfChanged(StandardDirectoryReader.java:257)
        at 
org.apache.lucene.index.DirectoryReader.openIfChanged(DirectoryReader.java:250)
        at org.apache.solr.core.SolrCore.openNewSearcher(SolrCore.java:1370)
        ... 38 more

I am clearly missing something here. I have triple checked the FQCN's i 
configure in the configuration, or in the 
services/org.apache.lucene.codecs.Codec file. What am i doing wrong?

Many thanks,
Markus

Reply via email to