Thanks for your quick response!  My jar was in solr/lib.  I removed all the 
<lib> directives from solrconfig.xml, but I still get the error.  My solr.xml 
doesn't have sharedLib.

By the way, I am running Solr 4.4.0 with most of the default example files 
(including solr.xml).  My schema.xml and solrconfig.xml are from another 
project using Solr 3.6.  I modified them a bit to fix any obvious errors.

I still wonder why it can create a new index using my codec, but not load an 
index previously created with my codec.  In solrconfig.xml, I specify the 
CodecFactory along with the package name, whereas the codec name that is read 
from the index file has no package name.  Could that be the problem?  I think 
that's the way it's supposed to be.  Could it be that Solr has my jar in the 
classpath, but SPI is not registering my codec class from the jar?  I'm not 
familiar with SPI.

What else can I try?

Thanks,
Scott


> -----Original Message-----
> From: Shawn Heisey [mailto:s...@elyograg.org]
> Sent: Tuesday, September 24, 2013 5:51 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Problem loading my codec sometimes
> 
> On 9/24/2013 6:32 PM, Scott Schneider wrote:
> > I created my own codec and Solr can find it sometimes and not other
> times.  When I start fresh (delete the data folder and run Solr), it
> all works fine.  I can add data and query it.  When I stop Solr and
> start it again, I get:
> >
> > Caused by: java.lang.IllegalArgumentException: A SPI class of type
> org.apache.lucene.codecs.Codec 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:
> [SimpleText, Appending, Lucene40, Lucene3x, Lucene41, Lucene42]
> >
> > I added the JAR to the path and I'm pretty sure Java sees it, or else
> it would not be using my codec when I start fresh.  (I've looked at the
> index files and verified that it's using my codec.)  I suppose Solr is
> asking SPI for my codec based on the codec class name stored in the
> index files, but I don't see why this would fail when a fresh start
> works.
> 
> What I always recommend for those who want to use custom and contrib
> jars is that they put all such jars (and their dependencies) into
> ${solr.solr.home}/lib, don't use any <lib> directives in
> solrconfig.xml,
> and don't put the sharedLib attribute into solr.xml.  Doing it in any
> other way has a tendency to trigger bugs or causes jars to get loaded
> more than once.
> 
> The ${solr.solr.home} property defaults to $CWD/solr (CWD is current
> working directory for those who don't already know) and is the location
> of the solr.xml file.  Note that depending on the exact version of Solr
> and which servlet container you are using, there may actually be two
> solr.xml files, one which loads solr into your container and one that
> configures Solr.  I am referring to the latter.
> 
> If you are using the solr example and its directory layout, the
> directory you would need to put all jars into is example/solr/lib ...
> which is a directory that doesn't exist and has to be created.
> 
> http://wiki.apache.org/solr/Solr.xml%20%28supported%20through%204.x%29
> http://wiki.apache.org/solr/Solr.xml%204.4%20and%20beyond
> 
> Thanks,
> Shawn

Reply via email to