title: NoClassDefFoundError: org/bouncycastle/jce/spec/ECPublicKeySpec even though bouncycastle is available
body: <p>I have a tomcat 8.5 running and deployed my application on it.
  While compiling everything is fine but at runtime the following error occurs:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/bouncycastle/jce/spec/ECPublicKeySpec
  org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi.engineGeneratePublic(Unknown Source)
  java.security.KeyFactory.generatePublic(KeyFactory.java:334)
  COMPANY.server.impl.BouncyCastleCrypto.decodePublicKey(BouncyCastleCrypto.java:87)
  COMPANY.server.impl.U2FServerReferenceImpl.processSignResponse(U2FServerReferenceImpl.java:270)
  COMPANY.tools.httpserver.servlets.SignFinishServletImpl.doGet(SignFinishServletImpl.java:41)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>This is all of the stacktrace I get.</p>
  
  <p>I already tried several versions of the bouncycastle dependency (1.58 and 1.50, I use maven) bcprov-jdk15on. I looked inside the produced .war file and the WEB-INF folder contains the jar. I tried re-downloading the maven dependency, did a project clean and maven clean in eclipse.</p>
  
  <p>Also I added the appropriate line to the java.security file:</p>
  
  <pre><code>security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
  </code></pre>
  
  <p>The strange thing is, that I can access the ECPublicKeySpec at some point. E.g:</p>
  
  <pre><code>ECPublicKeySpec ecPublicKeySpec = new ECPublicKeySpec(point,
        new ECParameterSpec(
            curve.getCurve(),
            curve.getG(),
            curve.getN(),
            curve.getH()));
    logger.info(ecPublicKeySpec.toString());
  </code></pre>
  
  <p>The above works fine but:</p>
  
  <pre><code>KeyFactory.getInstance("ECDSA").generatePublic(ecPublicKeySpec);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>KeyFactory.getInstance("ECDSA", "BC").generatePublic(ecPublicKeySpec);
  </code></pre>
  
  <p>This does not work and produces the NoClassDefFoundError.</p>
  
  <p>EDIT: Forgot to mention: If I deploy my application to my tomcat at localhost it works. If I deploy it to a remote tomcat it does not work.</p>
  
  <p>EDIT2: Output of <code>mvn dependency:tree -Dverbose -Dincludes=org/bouncycastle/jce/spec/ECPublicKeySpec</code>:</p>
  
  <pre><code>[WARNING] 
  [WARNING] Some problems were encountered while building the effective settings
  [WARNING] Unrecognised tag: 'profiles' (position: START_TAG seen ...&lt;/profile&gt;\n     &lt;profiles&gt;... @276:16)  @ /Users/tinoa/.m2/settings.xml, line 276, column 16
  [WARNING] 
  [INFO] Scanning for projects...
  [INFO] 
  [INFO] ------------------------------------------------------------------------
  [INFO] Building application_implemented 0.0.1-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  [INFO] 
  [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ application_implemented ---
  ...
  lots of "Downloading/Downloaded" lines...
  ...
  Downloaded: 
  https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
  invoker/2.0.11/maven-invoker-2.0.11.jar (29 kB at 22 kB/s)
  Downloaded: 
  https://repo.maven.apache.org/maven2/org/eclipse/aether/aether-
  util/0.9.0.M2/aether-util-0.9.0.M2.jar (134 kB at 102 kB/s)
  Downloaded: https://repo.maven.apache.org/maven2/commons-lang/commons-
  lang/2.6/commons-lang-2.6.jar (284 kB at 200 kB/s)
  Downloaded: https://repo.maven.apache.org/maven2/commons-
  collections/commons-collections/3.2.1/commons-collections-3.2.1.jar 
  (575 kB at 333 kB/s)
  [INFO] ----------------------------------------------------------------
  --------
  [INFO] BUILD SUCCESS
  [INFO] ----------------------------------------------------------------
  --------
  [INFO] Total time: 15.216 s
  [INFO] Finished at: 2017-10-10T15:05:40+02:00
  [INFO] Final Memory: 17M/297M
  [INFO] ------------------------------------------------------------------------
  </code></pre>