java.lang.NoClassDefFoundError only in particular conditions
<p>My problem is that when class B tries to use A.check() my execution stops due to a java.lang.NoClassDefFoundError.</p>

<p>So here is my class configuration. NB: the classes are in the same packages and I have already checked that the A.class file is placed where it should be.</p>

<pre><code>public class A{
    // vars 

    // declare some public method

    public synchronized static boolean check(){
           //do stuff, log some info and return boolean
    }
}

public class B implements Runnable{
    public void run() {
        A.check();
    }
}
</code></pre>

<p>And here is my stacktrace:</p>

<blockquote>
  <p>java.lang.NoClassDefFoundError:
  org/mypackage/A
  at org/mypackage.B.run()
  at java.lang.Thread.run(Thread.java:745) 
  Caused by: java.lang.ClassNotFoundException:
  org/mypackage.B
   at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)</p>
</blockquote>

<p>The project is really big and class A is used lots of times before this call without any problem, so i don't think that is something relative to the classpath. Note that this is part of the last call of the software that should close up everything.</p>

<p>Moreover, I have two maven goals: the first one execute the questioned code without any problem, instead the second rise this error every time.</p>