重新部署应用程序时,Bouncycastle无法加载 [英] Bouncycastle cannot load when I redeploy application

查看:399
本文介绍了重新部署应用程序时,Bouncycastle无法加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照以下说明添加了bouncycastle:
http://www.bouncycastle.org / wiki / display / JA1 / Provider + Installation
,但我仍然遇到一个问题。有时,当我重新部署应用程序时,找不到该提供程序,因此我的应用程序抛出异常。此问题每100个重新部署仅发生一次(可能更少)。当我重新启动服务器-weblogic时,它将再次开始工作。我将非常感谢为什么出现此问题的任何建议

I follow this instruction to add bouncycastle: http://www.bouncycastle.org/wiki/display/JA1/Provider+Installation but I have still one problem. Sometimes when I redeploy my application this provider isnt found so then my application throw exception. This problem occurs just one per 100 redeploy (maybe less). When I restart my server - weblogic then it start working again. I will be very grateful for any advice why this problem occurs

编辑:

我在上面的链接,因为当我只使用其中之一时,它就不起作用
我将这个提供者添加到java.security中,然后在我的课堂上注册了这个提供者:

I am using both method in link above because when I use just one of them then it doesnt work I add to java.security this provder and then in my class I registered this provder:

static {
    Security.addProvider(new BouncyCastleProvider());
}


推荐答案

您可能得到了 NoClassDefFoundError 。这是JSSE实现中的一个已知问题。

You probably got a NoClassDefFoundError. This is a known issue with JSSE implementations.

这里是这种情况:


  • 您的容器在特定于应用程序的ClassLoader中加载有弹力的城堡类

  • 您创建的提供程序实例取决于该类,以及此类加载器

  • ,然后由于顶级JVM ClassLoader中的静态字段,提供程序已注册到JRE API中。

  • 重新部署时,容器会丢弃应用程序ClassLoader来创建新的应用程序。

  • 由于已经知道该算法,因此第二个提供程序插入会以静默方式失败

  • 使用该算法时,提供程序实例完全不可用,因为ClassLoader已被丢弃

  • 然后唯一的选择是重新启动容器以解决问题。

  • Your container loads bouncy castle classes in an application specific ClassLoader
  • The provider instance you create depends on that classes and so on that ClassLoader
  • Then the provider is registered into JRE API thanks to static fields in top level JVM ClassLoader
  • When redeploying, the container discards the application ClassLoader to create a new one
  • As the algorithm is already known, the second provider insertion fails silently
  • When using the algorithm the provider instance is simply unusable because the ClassLoader has been discarded
  • Then the only option is to restart the container to get the situation fixed.

由于没有用于undeploy事件的标准侦听器,则无法同时触发JSSE提供程序删除。

As there is no standard listener for the undeploy event, it is not possible to trigger the JSSE provider removal at time.

避免这种麻烦的一种改进方法是在JVM ClassPath或容器ClassPath中具有充气城堡类。您必须将其从应用程序中删除。现在,您需要使用静态初始化程序的替代选项注册BC提供程序。 WebLogic提供了在服务器启动时触发代码的方式 (我使用过服务器启动类),此代码将负责在整个服务器/ JVM生命周期中注册JSSE提供程序。

The recommended way to avoid that trouble is to have bouncy castle classes in your JVM ClassPath or in your container ClassPath. You have to remove it from your application. Now you need to register BC provider with an alternate option to the static initializer. WebLogic provides ways to trigger code at server startup (I have used server startup class), this code will be responsible to register JSSE providers for the whole server/JVM lifetime.

另一种选择是添加以下行在带有 jre / lib / ext 的充气城堡的JRE java.security 文件中,但是我不喜欢这种方式,因为更新时可能会丢失: security.provider.7 = org.bouncycastle.jce.provider.BouncyCastleProvider

An alternate option is to add the following line in JRE java.security file with bouncy castle jar in jre/lib/ext but I do not like that way because it may be lost when updating: security.provider.7=org.bouncycastle.jce.provider.BouncyCastleProvider

因此,应用程序只希望实现就可以了,最好添加算法可用性测试以将任何故障报告给运营商和用户。

So then the application simply expects implementations are there, it may be a good idea to add tests for algorithm availability to report any troubles to operators and users.

这篇关于重新部署应用程序时,Bouncycastle无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆