title: java NoClassDefFoundError but Class is there and Usable
body: <p>i have a very strange(for me) Question. I use bouncy castle to de-/crypt some Mails in a Web Application. I get this Exception after redeployment of my Application</p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError: org/bouncycastle/jcajce/spec/SkeinParameterSpec
            at org.bouncycastle.jcajce.provider.symmetric.util.BaseMac.engineInit(Unknown Source)
            at javax.crypto.Mac.init(Mac.java:443)
            at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.calculatePbeMac(Unknown Source)
            at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(Unknown Source)
            at java.security.KeyStore.load(KeyStore.java:1445)
            at <em>my.application.Class</em>.getDecryptedContent(<em>my.application.Class</em>.java:401)
            at <em>my.application.Class</em>.decrypt(<em>my.application.Class</em>.java:91)
            at <em>my.application.Class</em>.getKvConnectMail(<em>my.application.Class</em>.java:320)
            at <em>my.application.Class</em>.processEinClick(<em>my.application.Class</em>.java:198)
            at <em>my.application.Class</em>.shedule(<em>my.application.Class</em>.java:44)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:497)
            at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
            at org.springframework.scheduling.support.MethodInvokingRunnable.run(MethodInvokingRunnable.java:65)
            at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:51)
            at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)</p>
  </blockquote>
  
  <p>So i thought the lib is missing in WEB-INF/lib folder of my Application but it is there.</p>
  
  <p>The strange thing is: If i use the Class direct with this Codesnipped the Snipped is executed correct without errors. </p>
  
  <pre><code>LOGGER.error("Class!!!: " + SkeinParameterSpec.class.getName());
  SkeinParameterSpec spec = new SkeinParameterSpec();
  LOGGER.error("Instance!!!: " + spec.toString());
  LOGGER.error("Instanceof: " + (spec instanceof SkeinParameterSpec));
  </code></pre>
  
  <p>But the Library Class org.bouncycastle.jcajce.provider.symmetric.util.BaseMac which uses near the same code as my snipped ends with the Exception above.</p>
  
  <p>Somebody out there who can help me to understand why this happens?</p>
  
  <p>P.S.:
  This only happens after a redeployment if restart the whole Tomcat every thinks works.</p>
  
  <p><strong>UPDATE 1:</strong>
  I have forgotten to say that i use Liferay. But my WebApplication is a normal one without any relations to Liferay.</p>
  
  <p>But: After some investigation i found out that Liferay have some librarys (/tomcat/webapps/ROOT/lib). Also Bouncycastle in an old version. Is it possible that this librarys are used by my WebApplication and the error is a result of Liferay's librarys and CustomClassLoaders?</p>
  
  <p><strong>Solution:</strong>
  See 'inigo skimmer' comment at the right answer.</p>