title: OpenJDK 11 error "Can not initialize cryptographic mechanism"
body: <p>I have an app written with openJDK (Amazon Correto 11) and openJFX.</p>
  
  <p>When I run the app locally - everything works. 
  But when I execute the app from network share there is an Exception: </p>
  
  <pre><code>java.lang.ExceptionInInitializerError
      at java.base/javax.crypto.JceSecurityManager.&lt;clinit&gt;(JceSecurityManager.java:65)
      at java.base/javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2624)
      at java.base/javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2646)
      at java.base/sun.security.ssl.SSLCipher.isUnlimited(SSLCipher.java:540)
      at java.base/sun.security.ssl.SSLCipher.&lt;init&gt;(SSLCipher.java:472)
      at java.base/sun.security.ssl.SSLCipher.&lt;clinit&gt;(SSLCipher.java:174)
      at java.base/sun.security.ssl.CipherSuite.&lt;clinit&gt;(CipherSuite.java:67)
      at java.base/sun.security.ssl.SSLContextImpl.getApplicableSupportedCipherSuites(SSLContextImpl.java:348)
      at java.base/sun.security.ssl.SSLContextImpl$AbstractTLSContext.&lt;clinit&gt;(SSLContextImpl.java:579)
      at java.base/java.lang.Class.forName0(Native Method)
      at java.base/java.lang.Class.forName(Class.java:315)
      at java.base/java.security.Provider$Service.getImplClass(Provider.java:1848)
      at java.base/java.security.Provider$Service.newInstance(Provider.java:1824)
      at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
      at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
      at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:168)
      at org.apache.http.ssl.SSLContexts.createDefault(SSLContexts.java:51)
      at org.apache.http.conn.ssl.SSLConnectionSocketFactory.getSocketFactory(SSLConnectionSocketFactory.java:194)
      at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:115)
      at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.&lt;init&gt;(PoolingHttpClientConnectionManager.java:122)
      at com.mashape.unirest.http.options.Options.refresh(Options.java:72)
      at com.mashape.unirest.http.options.Options.&lt;clinit&gt;(Options.java:46)
      at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
      at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
      at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
      at myapp.util.MyTaxNumberValidator$3.run(MyTaxNumberValidator.java:185)
      at java.base/java.lang.Thread.run(Thread.java:834)
  Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
      at java.base/javax.crypto.JceSecurity.&lt;clinit&gt;(JceSecurity.java:120)
      ... 27 more
  Caused by: java.lang.SecurityException: Can't read cryptographic policy directory: unlimited
      at java.base/javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:326)
      at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:111)
      at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:108)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/javax.crypto.JceSecurity.&lt;clinit&gt;(JceSecurity.java:107)
      ... 27 more
  </code></pre>
  
  <p>I run an app using command:</p>
  
  <p><code>\\\some-network-share\app\jre\bin\javaw.exe -jar myapp.jar</code></p>
  
  <p>because on this network share I've copied Amazon Correto 11 JDK files and other libs I use for the app.</p>
  
  <p>I run get request in another thread and this thread throws an exception.</p>
  
  <p>How can I overcome the problem? </p>
  
  <p>Please help.</p>
  
  <p>I've tried different libs: 
  1. OkHttpClient
  2. Java Unirest</p>
  
  <p>but in both the same error. </p>
  
  <pre class="lang-java prettyprint-override"><code>
  public class MyGetExecutor {
  
  
      public static void main(String[] args) {
  
          Thread getThread = new Thread( new Runnable() {
  
              @Override
              public void run() {
  
                  try {
                      logMessage.add( "Before request" );
                      com.mashape.unirest.http.HttpResponse&lt;String&gt; response = Unirest.get("https://myappserver.domain.com/api/v1/users/1")
                      .header("User-Agent", "PostmanRuntime/7.17.1")
                      .header("Accept", "*/*")
                      .header("Cache-Control", "no-cache")
                      .header("Postman-Token", "abf4b45d-a2c5-4f53-b4e3-1fa29643d616,e59130fc-5ce0-4b70-af48-ab3808362e36")
                      .header("Host", "wf01.cdprojektred.com")
                      .header("Accept-Encoding", "gzip, deflate")
                      .header("Cookie", "JSESSIONID=2C71F035C2EDFF145FED5C03C4887EF1")
                      .header("Connection", "keep-alive")
                      .header("cache-control", "no-cache")
                      .asString();
                      logMessage.add( "After request" );
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      logMessage.add( "Exception in getThread: " + e.getMessage() );
                  }
  
  
              }
  
          }, "Get-thread");
          getThread.setUncaughtExceptionHandler(
                  new Thread.UncaughtExceptionHandler() {
                      @Override
                      public void uncaughtException(Thread t, Throwable e) {
                          logMessage.add( "Error in thread: " + e );
                          logMessage.add( "Details: " + e.getCause().getMessage() );
                      }
                  }
              );
          getThread.start();
  
          while( getThread.isAlive() ) {
  
              try {
                  Thread.sleep(1000);
                  logMessage.add("Main thread sleeping...");
              } catch (Exception e) {
                  logMessage.add("Exception in main thread...: " + e.getMessage());
              }
  
  
  
          }
  
      }
  }
  </code></pre>
  
  <p><strong>EDIT 1</strong> I've added additional stacktrace - please check</p>