Bonjour,

Nous travaillons avec Eclipse et nous avons un projet java sous Maven (P1) qui dépend d'un premier projet (P2) qui utilise une librarie apache lucene (trois librairies core, queryparser et common-analyzers - ces 2 derniers utilisent core).
Tant qu'on est sous Eclipse, le projet P1 s'exécute normalement. Mais dans un client externe, on a toujours l'erreur ci-dessous ou une approchant dans la suivante, si on rajoute lucene-core dans les jar du client:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriterConfig.java:122)
at org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:148)
...
Caused by: java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec 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: []
at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)
at org.apache.lucene.codecs.Codec.forName(Codec.java:95)
at org.apache.lucene.codecs.Codec.<clinit>(Codec.java:122)
... 10 more
Ou quand le jar de lucene-core est au niveau du client
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.lucene.codecs.lucene40.Lucene40Codec.<init>(Lucene40Codec.java:53)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:374)
at java.lang.Class.newInstance(Class.java:327)
at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:67)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:45)
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>(LiveIndexWriterConfig.java:122)
at org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:148)
at fr.grisa.servo.index.IndexOnto.<init>

...
Caused by: java.lang.ClassCastException: class org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat
at java.lang.Class.asSubclass(Class.java:3046)
at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:137)
at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:65)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:47)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
at org.apache.lucene.codecs.PostingsFormat.<clinit>(PostingsFormat.java:44)
... 22 more
En vérifiant dans le jar généré du projet p1, on a bien dans META-INF/services/org.apache.lucene.codecs.Codec les lignes suivantes:
org.apache.lucene.codecs.lucene40.Lucene40Codec
org.apache.lucene.codecs.lucene3x.Lucene3xCodec
org.apache.lucene.codecs.lucene41.Lucene41Codec
org.apache.lucene.codecs.lucene42.Lucene42Codec
Nous avons eu ce problème avec la version 4 de Lucene, actuellement on a la 4.4.0.

Avec Maven shade on a tenté les configurations suivantes sans succès:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                 </transformer>
                  <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer">
                 </transformer>
Et en refaisant un projet classique Java de P1 avant de l'exporter, le soucis est le même.

Quelqu'un pourrait nous aider ?

Merci,
dkibaro