title: Maven packaging fail Lucene, SPI does not exist Exception
body: <p>I built a Java application for indexing. I am using Apache Lucene 5.3.1.
  When I run the application in IDE (IntelJ IDEA 2016.1.1 Community Edition), it runs normally. When I try to run the application from jar file I get this exception</p>
  
  <pre><code>Exception in thread "main" java.util.ServiceConfigurationError: Cannot instantiate SPI class: org.apache.lucene.codecs.lucene53.Lucene53Codec
      at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:77)
      at org.apache.lucene.util.NamedSPILoader.&lt;init&gt;(NamedSPILoader.java:47)
      at org.apache.lucene.util.NamedSPILoader.&lt;init&gt;(NamedSPILoader.java:37)
      at org.apache.lucene.codecs.Codec$Holder.&lt;clinit&gt;(Codec.java:47)
      at org.apache.lucene.codecs.Codec.getDefault(Codec.java:140)
      at org.apache.lucene.index.LiveIndexWriterConfig.&lt;init&gt;(LiveIndexWriterConfig.java:120)
      at org.apache.lucene.index.IndexWriterConfig.&lt;init&gt;(IndexWriterConfig.java:140)
     .
     .
  Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist.      You need to add the corresponding JAR file supporting
  this SPI to your classpath.  The current classpath supports the following names: [IDVersion]
      at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)
      at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
      at org.apache.lucene.codecs.lucene53.Lucene53Codec.&lt;init&gt;(Lucene53Codec.java:160)
      at org.apache.lucene.codecs.lucene53.Lucene53Codec.&lt;init&gt;(Lucene53Codec.java:80)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:67)
      ... 13 more
  </code></pre>
  
  <p>There is a similar issue <a href="http://www.gossamer-threads.com/lists/lucene/java-user/190786" rel="nofollow">here</a> , but the solution with maven-shade-plugin didn't help.
  Here is pom.xml related segments.</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
              &lt;artifactId&gt;lucene-core&lt;/artifactId&gt;
              &lt;version&gt;5.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
              &lt;artifactId&gt;lucene-analyzers-common&lt;/artifactId&gt;
              &lt;version&gt;5.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
              &lt;artifactId&gt;lucene-queryparser&lt;/artifactId&gt;
              &lt;version&gt;5.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
              &lt;artifactId&gt;lucene-codecs&lt;/artifactId&gt;
              &lt;version&gt;5.3.1&lt;/version&gt;
          &lt;/dependency&gt;
      ...
      &lt;transformers&gt;
          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
              &lt;resource&gt;META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory&lt;/resource&gt;
          &lt;/transformer&gt;
          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
              &lt;resource&gt;META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory&lt;/resource&gt;
          &lt;/transformer&gt;
          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
              &lt;resource&gt;META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory&lt;/resource&gt;
          &lt;/transformer&gt;
          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
              &lt;resource&gt;META-INF/services/org.apache.lucene.codecs.Codec&lt;/resource&gt;
          &lt;/transformer&gt;
          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
              &lt;resource&gt;META-INF/services/org.apache.lucene.codecs.DocValuesFormat&lt;/resource&gt;
          &lt;/transformer&gt;
          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
              &lt;resource&gt;META-INF/services/org.apache.lucene.codecs.PostingsFormat&lt;/resource&gt;
          &lt;/transformer&gt;
  &lt;/transformers&gt;
  </code></pre>
  
  <p>The problem is that for some reason it tries to load something from Lucene50. </p>
  
  <p>Any help is valuable! </p>