title: unexpected exception: java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
body: <p>I'm developing a GWT application. It's using RPC to collect information from an internal system. It does so by using a library jar, lets call it alpha.jar. We are using this jar in many application so it works fine, and btw its built with ANT, outside eclipse.</p>
  
  <p>Some classes in alpha.jar references LOG4J2 and also lots of other external jars, so <strong>when we run an application we pass a classpath to all those, and everything works out fine</strong>. Please note that this is not a simple beginners problem. The alpha.jar is working as it should, including calls to Log4J.</p>
  
  <p>The problem:</p>
  
  <p>In Eclipse, I have this GWT application project and also the Alpha.jar project (with source code of course). The server part needs to instatiate alpha objects and communicate to the alpha system.</p>
  
  <p>When do this in GWT by adding a build-path-reference to the Alpha project, my GWT app runs fine.</p>
  
  <p>When I instead of the project reference include (in war/WEB-INF/lib) the alpha.jar and runs the app, I get the error in the title the first time I instantiate a class from alpha.jar.</p>
  
  <p>There are no peculiarities in how the alpha.jar is built, so basically it should be the same thing as the project in eclipse, right?</p>
  
  <p>Note the following:</p>
  
  <p>*) The alpha.jar's dependent jars are also in war/WEB-INF/lib. log4j2-core, log4j-api as well as a bunch of others (apache common for example)</p>
  
  <p>*) If I remove the alpha.jar (and the code that calls it) and instead just add code that called LOG4J2, that code also works fine!</p>
  
  <p>How come I get this weird error when using the JAR?? Note also the NoClassDefFoundError, its not the more common ClassNotFoundException. Pls see <a href="https://stackoverflow.com/questions/1457863/what-is-the-difference-between-noclassdeffounderror-and-classnotfoundexception">What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?</a></p>
  
  <p>If you need more info let me know.</p>