java - 无法加载 [org.bouncycaSTLe.jcajce.provider.digest.GOST3411$Mappings]

标签 java spring tomcat8 bouncycastle

我使用 tomcat8 服务器,.bouncycaSTLe 进行文档签名。 我的服务器上已经运行了一个 war 文件。当我为我的第二个项目部署新的 war 文件时,出现以下异常。

我已经点击并尝试了 stackoverflow 上的每个链接,但运气不佳

org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [org.bouncycastle.jcajce.provider.digest.GOST3411$Mappings]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access. java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load

 public static void xmlSigner(File xmlFile,String pfxFilePath){
    try{
            File pfxFile=new File(pfxFilePath);
            Security.addProvider(new BouncyCastleProvider());
            log.info("Above key store ");
            KeyStore keyStore = KeyStore.getInstance("pkcs12", "BC");
            log.info("below key store ");
            keyStore.load(new FileInputStream(pfxFile),password.toCharArray());
            log.info("load pfx file key store ");
            String alias = (String) keyStore.aliases().nextElement();
            PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray());
            Certificate[] certificateChain = keyStore.getCertificateChain(alias);
            X509Certificate publickeyCertificate = (X509Certificate) certificateChain[certificateChain.length - 1];
            //log.info("privateKey : " + privateKey);
            //log.info("xmlSigner : " + xmlFile);
            log.info("SignerClient - Above Sign and Zip");
            SignerUtil.signAndzipFile(xmlFile, privateKey, publickeyCertificate);
            log.info("Successfully Signed");
        }
        catch(Exception xmlSignerException){
            log.error("xmlSigner : ", xmlSignerException);
            xmlSignerException.printStackTrace();

        }

   }

我在下面的行中遇到异常

KeyStore keyStore = KeyStore.getInstance("pkcs12", "BC");

最佳答案

我也遇到了同样的问题,重启Tomcat就解决了问题。

keystore = KeyStore.getInstance("PKCS12", "BC");
// java.security.KeyStoreException: PKCS12 not found
Caused by: java.security.NoSuchAlgorithmException: class configured for KeyStore (provider: BC) cannot be found.
    at java.security.Provider$Service.getImplClass(Provider.java:1649)
    at java.security.Provider$Service.newInstance(Provider.java:1592)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
    at java.security.Security.getImpl(Security.java:698)
    at java.security.KeyStore.getInstance(KeyStore.java:896)
    ... 11 more
Caused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi$BCPKCS12KeyStore]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1354)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1211)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1172)
    at java.security.Provider$Service.getImplClass(Provider.java:1636)
    ... 16 more
Caused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi$BCPKCS12KeyStore]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1364)
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1352)
    ... 19 more

关于java - 无法加载 [org.bouncycaSTLe.jcajce.provider.digest.GOST3411$Mappings],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56836527/

相关文章:

java - spring 初始化的 bean 能活多久?

java - 忽略 web.xml 中重复的 servlet 映射

java - <jsp :include> not respecting position styles of the jsp included

java - 如何使用 Spring MVC 覆盖 Jetty 的 404 错误?

java - 在 Java 中拖动形状

java - Spring 安全抛出 javax.servlet.ServletException : Could not resolve view with name 'j_spring_security_check'

Java:如何将 com.google.api.services.drive.model.File 转换为 InputStream?

tomcat - 如何使用mod_jk 配置apache2 和Tomcat8?

ssl - 在 tomcat 8 中启用 SSL

java - ExecutorService awaitTermination 方法未按预期执行