lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manivannan Selvadurai <manivan...@unmetric.com>
Subject Re: Cannot instantiate SPI class: org.apache.lucene.codecs.lucene42.Lucene42Codec
Date Wed, 10 Apr 2013 07:15:00 GMT
you are exactly correct...we found this out and removed the facets, codecs
jar and fixed the issue for now.We will explore the maven option.  Thanks
again for the reply


On Wed, Apr 10, 2013 at 12:09 PM, Uwe Schindler <uwe@thetaphi.de> wrote:

> Hi Manivannan,
> > thanks for the reply.
> > Im not using any custom class loaders, I tried using the 4.2.1, i got
> the same
> > issue, facet42 is found, but not lucene42.
> > i have the facet.jar in my final jar.
> >         <pathelement
> > > location="../libs/luceneV4.2/lucene-codecs-4.2.0.jar"/>*
> > > *        <pathelement location="../libs/luceneV4.2/
> > lucene-core-4.2.0.jar"/>*
> > > *        *<pathelement location="../libs/luceneV4.2/**
> > lucene-facet-4.2.0.jar"/>*
> >
> >
> >
> > One more information., when i run this program from my IDE(eclipse), it
> > works and creates the index, It only fails when i create a jar out of my
> project
> > and try to run from the jar.
>
> This was the *important* information we were missing. Now everything is
> easy to explain. The problem you have is:
> You are using a simple ANT task that merges all JAR files into one big
> one, and that is the problem. Lucene uses SPI (Service Provider Interface,
> see http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.htmlfor help and
information how services discovery works) to "discover" all
> components ("codecs", "postings formats", "analyzers")  from the different
> JAR files. For discovery every JAR file contains some metadata files inside
> the META-INF/services directory. The lucene-core.jar file and the
> lucene-facet.jar file both contain such files, but they have the same name!
> If you simply merge the JAR files by copying all separate JAR file contents
> into one, the META-INF/services files are conflicting and replace each
> other while this process is running.
>
> In your case, the lucene-core.jar file is first added to your final JAR,
> placing the META-INF/services files inside your JAR, but later,
> lucene-facet.jar is added to the final JAR file, too - overwriting the file
> in the final JAR. Because of this, Lucene only sees the facet "codecs", but
> no longer the core ones (see the list of "supported codecs" printed in the
> error message, 2nd stack trace: [facet42] instead of [lucene42,
> facet42,...]).
>
> You have 2 possibilities, choose one:
> - Don't merge the JAR files to one big one!
> - Don't use a simple copy ANT task to merge, because the META-INF metadata
> must be merged (means the META-INF/services files with same name must be
> appended in the final JAR). The Maven-Shade plugin for creating such "Uber
> JARs" can do this for you, but there are other possibilities (see
> http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
> ).
>
> There is one third alternative, but it may only help you to quickly fix
> the problem:
> - You seem to add *all* Lucene JARs (also possibly not needed ones) to the
> final classpath/JAR. If you don't use facets or custom codecs, don't add
> those files, then you don’t have the "merge" problem.
>
> Uwe
>
> > On Tue, Apr 9, 2013 at 6:03 PM, Uwe Schindler <uwe@thetaphi.de> wrote:
> >
> > > There may be 2 problems, to fix:
> > > a) use 4.2.1 (if you are using custom class loaders in your
> > > application)
> > > b) The stack trace says, that it can only find the codec "Facet42".
> > > This codec is only in lucene-facet.jar, but this JAR file is not in
> > > your classpath. So you seem to have some classpath problem.
> > >
> > > Uwe
> > >
> > > -----
> > > Uwe Schindler
> > > H.-H.-Meier-Allee 63, D-28213 Bremen
> > > http://www.thetaphi.de
> > > eMail: uwe@thetaphi.de
> > >
> > >
> > > > -----Original Message-----
> > > > From: Manivannan Selvadurai [mailto:manivannan@unmetric.com]
> > > > Sent: Tuesday, April 09, 2013 1:15 PM
> > > > To: java-user@lucene.apache.org
> > > > Subject: Re: Cannot instantiate SPI class:
> > > > org.apache.lucene.codecs.lucene42.Lucene42Codec
> > > >
> > > > i don't get what u mean by setup. im not using solr. Could u please
> > > > be
> > > more
> > > > specific.
> > > > we dont use maven for building the jar. Its just few build.xmls. It
> > > > is
> > > just plain
> > > > Lucene 4.2.
> > > > I have to create an index using some tokenizers and filters.
> > > >
> > > > with thanks,
> > > > Manivannan
> > > >
> > > >
> > > > On Tue, Apr 9, 2013 at 4:07 PM, Uwe Schindler <uwe@thetaphi.de>
> > wrote:
> > > >
> > > > > As mentioned in the original answer, what is the setup you are
> using?
> > > > >
> > > > > -----
> > > > > Uwe Schindler
> > > > > H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de
> > > > > eMail: uwe@thetaphi.de
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Manivannan Selvadurai [mailto:manivannan@unmetric.com]
> > > > > > Sent: Tuesday, April 09, 2013 12:33 PM
> > > > > > To: java-user@lucene.apache.org
> > > > > > Subject: Re: Cannot instantiate SPI class:
> > > > > > org.apache.lucene.codecs.lucene42.Lucene42Codec
> > > > > >
> > > > > > I dint understand what u mean by directly inside ant or just
for
> > > > > compiling, but
> > > > > > this is the process we do Im using the Lucene jars in a build.xml
> > > > > > and we
> > > > > use
> > > > > > ant to build the jar and i invoke the program on that resulting
> jar.
> > > > > >
> > > > > >
> > > > > > So will using lucene 4.2.1 fix the issue for me?
> > > > > >
> > > > > >
> > > > > > On Tue, Apr 9, 2013 at 3:50 PM, Uwe Schindler <uwe@thetaphi.de>
> > > > wrote:
> > > > > >
> > > > > > > This may be fixed in 4.2.1, but this depends on your setup.
Are
> > > > > > > you using Lucene directly inside ANT or is it just for
> compiling
> > > code?
> > > > > > >
> > > > > > > Uwe
> > > > > > >
> > > > > > > -----
> > > > > > > Uwe Schindler
> > > > > > > H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de
> > > > > > > eMail: uwe@thetaphi.de
> > > > > > >
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: Manivannan Selvadurai
> > [mailto:manivannan@unmetric.com]
> > > > > > > > Sent: Tuesday, April 09, 2013 11:52 AM
> > > > > > > > To: java-user@lucene.apache.org
> > > > > > > > Subject: Cannot instantiate SPI class:
> > > > > > > > org.apache.lucene.codecs.lucene42.Lucene42Codec
> > > > > > > >
> > > > > > > > Hi All,
> > > > > > > >
> > > > > > > >                I'm facing this problem.
> > > > > > > >  When i build a jar out of my project and try to run
the
> program
> > > > > > > > that
> > > > > > > invokes
> > > > > > > > lucene part of the code, it gives me this exception
> > > > > > > >
> > > > > > > > Exception in thread "main"
> java.util.ServiceConfigurationError:
> > > > > > > > Cannot instantiate SPI class:
> > > > > > org.apache.lucene.codecs.lucene42.Lucene42Codec
> > > > > > > >         at
> > > > > > > >
> > > > > >
> > > >
> > org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:72)
> > > > > > > >         at
> > > > > > > >
> > > > org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:42)
> > > > > > > >         at
> > > > > > > >
> > > > org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
> > > > > > > >         at
> org.apache.lucene.codecs.Codec.<clinit>(Codec.java:41)
> > > > > > > >         at
> > > > > > > >
> > > > org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriter
> > > > > > > > Confi
> > > > > > > > g.java:118)
> > > > > > > >         at
> > > > > > > >
> > > > org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.j
> > > > > > > > ava:1
> > > > > > > > 45)
> > > > > > > >  Caused by: java.lang.IllegalArgumentException: A
SPI class
> of
> > > type
> > > > > > > > org.apache.lucene.codecs.DocValuesFormat with name
> > 'Lucene42'
> > > > does
> > > > > > > > not exist. You need to add the corresponding JAR file
> supporting
> > > > > > > > this SPI to
> > > > > > > your
> > > > > > > > classpath.The current classpath supports the following
names:
> > > > > [Facet42]
> > > > > > > >         at
> > > > > > > >
> > > > > >
> > > >
> > org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:104)
> > > > > > > >         at
> > > > > > > >
> > > > > >
> > > >
> > org.apache.lucene.codecs.DocValuesFormat.forName(DocValuesFormat.jav
> > > > > > > > a:97)
> > > > > > > >         at
> > > > > > > >
> > > > > >
> > > >
> > org.apache.lucene.codecs.lucene42.Lucene42Codec.<init>(Lucene42Codec
> > > > > > > > .j
> > > > > > > > ava:130)
> > > > > > > >         at
> > > > > > > > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > > > > > > Method)
> > > > > > > >         at
> > > > > > > >
> > > > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruc
> > > > > > > > tor
> > > > > > > > AccessorImpl.java:39)
> > > > > > > >         at
> > > > > > > >
> > > > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Delegating
> > > > > > > > Con
> > > > > > > > structorAccessorImpl.java:27)
> > > > > > > >         at
> > > > > > > java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> > > > > > > >         at java.lang.Class.newInstance0(Class.java:357)
> > > > > > > >         at java.lang.Class.newInstance(Class.java:310)
> > > > > > > >         at
> > > > > > > >
> > > > > >
> > > >
> > org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:62)
> > > > > > > >         ... 7 more
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I have the entry in  build.xml like this
> > > > > > > >
> > > > > > > > *<path id="LuceneV4.2.userclasspath">*
> > > > > > > > *        <pathelement location="../libs/luceneV4.2/commons-
> > codec-
> > > > > > > > 1.7.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/commons-compress-1.4.1.jar"/>*
> > > > > > > > *        <pathelement
> > > location="../libs/luceneV4.2/icu4j-49.1.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/jakarta-regexp-1.4.jar"/>
> > > > > > > > *
> > > > > > > > *        <pathelement
> > > > > > > >
> > > location="../libs/luceneV4.2/lucene-analyzers-common-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> location="../libs/luceneV4.2/lucene-analyzers-icu-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> > > location="../libs/luceneV4.2/lucene-analyzers-kuromoji-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> > > > >
> location="../libs/luceneV4.2/lucene-analyzers-morfologik-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> > > location="../libs/luceneV4.2/lucene-analyzers-phonetic-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> > > location="../libs/luceneV4.2/lucene-analyzers-smartcn-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> > > location="../libs/luceneV4.2/lucene-analyzers-stempel-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> location="../libs/luceneV4.2/lucene-analyzers-uima-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-benchmark-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> location="../libs/luceneV4.2/lucene-classification-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-codecs-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/lucene-core-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/lucene-facet-4.2.0.jar"/>
> > > > > > > > *
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-grouping-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-highlighter-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/lucene-join-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-memory-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/lucene-misc-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-queries-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-queryparser-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-sandbox-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-spatial-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/lucene-suggest-4.2.0.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/morfologik-fsa-1.5.5.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > > location="../libs/luceneV4.2/morfologik-polish-1.5.5.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> location="../libs/luceneV4.2/morfologik-stemming-1.5.5.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/nekohtml-1.9.17.jar"/>*
> > > > > > > > *        <pathelement
> > > > > location="../libs/luceneV4.2/spatial4j-0.3.jar"/>*
> > > > > > > > *        <pathelement
> > > > > location="../libs/luceneV4.2/Tagger-2.3.1.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/uimaj-core-2.3.1.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > >
> location="../libs/luceneV4.2/WhitespaceTokenizer-2.3.1.jar"/>*
> > > > > > > > *        <pathelement
> > > > > > > location="../libs/luceneV4.2/xercesImpl-2.9.1.jar"/>*
> > > > > > > > *    </path>*
> > > > > > > >
> > > > > > > >
> > > > > > > > Please Help.
> > > > > > > >
> > > > > > > > --
> > > > > > > > *With Best Regards,*
> > > > > > > > *Manivannan *
> > > > > > >
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> > > > > > > For additional commands, e-mail: java-user-
> > help@lucene.apache.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > *With Best Regards,*
> > > > > > *Manivannan *
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > *With Best Regards,*
> > > > *Manivannan *
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
> >
> > --
> > *With Best Regards,*
> > *Manivannan *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
*With Best Regards,*
*Manivannan *

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message