Running an uber jar from sbt assembly results in error: Could not find or load main class : <p>I have a spark job packaged as an uber-jar using the sbt assembly plugin.
The <code>build.sbt</code> specifies a runnable main to be the target of the resulting uber-jar</p>

<pre><code>mainClass in assembly := Some("com.foo.Bar")
</code></pre>

<p>After the assembly is correctly created, running the intended command:</p>

<pre><code>java -jar assembly.jar
</code></pre>

<p>results in</p>

<blockquote>
  <p>Error: Could not find or load main class com.foo.Bar</p>
</blockquote>

<p>Using the an alternative method, like <code>java -cp assembly.jar com.foo.Bar</code> gives the same error message.</p>

<p>Then, I extracted the contents of the uber-jar in a new directory. I can see my <code>com/foo/</code> directory and the <code>Bar.class</code> file. 
From the root of the extracted directory I tried:</p>

<pre><code>java -cp . com.foo.Bar
</code></pre>

<p>and I get a correct result.</p>

<p>Further trying to find the reason of the error, I tried:</p>

<pre><code>java -verbose -jar assembly.jar
</code></pre>

<p>I can see the java core classes being loaded, but I don't see any of my packaged classes being loaded.</p>

<p>What can possibly be wrong here?</p>
