title: Maven exec:java run executable plugin dependency jar results in NPE
body: <p>I'm making a maven application that uses a sparql endpoint service. I'd like to have a maven goal to download the sparql endpoint and start the service but it seems that maven have some problems to configure the classpath. </p>
  
  <p>I'm using blazegraph and its artifact at <a href="https://mvnrepository.com/artifact/com.blazegraph/bigdata-jar" rel="nofollow noreferrer">https://mvnrepository.com/artifact/com.blazegraph/bigdata-jar</a>.</p>
  
  <p>Here it is my plug-in configuration in pom.xml:</p>
  
  <pre><code>&lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.6.0&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;java&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;mainClass&gt;com.bigdata.rdf.sail.webapp.StandaloneNanoSparqlServer&lt;/mainClass&gt;
                  &lt;includePluginDependencies&gt;true&lt;/includePluginDependencies&gt;
                  &lt;includeProjectDependencies&gt;false&lt;/includeProjectDependencies&gt;
                  &lt;executableDependency&gt;
                      &lt;groupId&gt;com.blazegraph&lt;/groupId&gt;
                      &lt;artifactId&gt;blazegraph-jar&lt;/artifactId&gt;
                  &lt;/executableDependency&gt;
                  &lt;addOutputToClasspath&gt;false&lt;/addOutputToClasspath&gt;
              &lt;/configuration&gt;
              &lt;dependencies&gt;
                  &lt;!-- https://mvnrepository.com/artifact/com.blazegraph/blazegraph-jar --&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;com.blazegraph&lt;/groupId&gt;
                      &lt;artifactId&gt;blazegraph-jar&lt;/artifactId&gt;
                      &lt;version&gt;2.1.4&lt;/version&gt;
                      &lt;scope&gt;runtime&lt;/scope&gt;
                      &lt;type&gt;jar&lt;/type&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>The debug output hints that the plug-in can't find the artifact:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
  at org.codehaus.mojo.exec.AbstractExecMojo.findExecutableArtifact(AbstractExecMojo.java:278)
  at org.codehaus.mojo.exec.ExecJavaMojo.determineRelevantPluginDependencies(ExecJavaMojo.java:650)
  at org.codehaus.mojo.exec.ExecJavaMojo.addRelevantPluginDependenciesToClasspath(ExecJavaMojo.java:568)
  at org.codehaus.mojo.exec.ExecJavaMojo.getClassLoader(ExecJavaMojo.java:520)
  at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:301)
  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
  ... 27 more
  </code></pre>
  
  <p>What am I missing? </p>
  
  <p><strong>Edit 1</strong>
  This question is not a duplicate of <a href="https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it">What is a NullPointerException, and how do I fix it?</a> because the exception is thrown by Maven since it can't find the right artifact in the list of dependencies (but it should).</p>
  
  <p><strong>Edit 2</strong>
  Thanks to @Sean Patrick Floyd I've partially solved the issue. There are still some problem in the classpath configuration, I guess. Now Maven finds the main class and the jar but after the execution I get an other NPE in compiled code. Looking in the open source code of blazegraph it seems that it can't open a resource inside the executable jar.</p>
  
  <p>Here is the line that causes NPE: </p>
  
  <pre><code>System.setProperty("jetty.home",
              jettyXml.getClass().getResource("/war").toExternalForm());
  </code></pre>
  
  <p><a href="https://github.com/blazegraph/database/blob/master/bigdata-jar/src/main/java/com/bigdata/rdf/sail/webapp/StandaloneNanoSparqlServer.java#L142" rel="nofollow noreferrer">https://github.com/blazegraph/database/blob/master/bigdata-jar/src/main/java/com/bigdata/rdf/sail/webapp/StandaloneNanoSparqlServer.java#L142</a>  </p>