gpt4 book ai didi

java - NoClassDefFoundError : org/bouncycaSTLe/jce/spec/ECPublicKeySpec even though bouncycaSTLe is available

转载 作者:行者123 更新时间:2023-11-30 10:24:09 54 4
gpt4 key购买 nike

我有一个 tomcat 8.5 正在运行并在上面部署了我的应用程序。虽然编译一切正常,但在运行时出现以下错误:

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)

这是我得到的所有堆栈跟踪信息。

我已经尝试了几个版本的 bouncycaSTLe 依赖项(1.58 和 1.50,我使用 maven)bcprov-jdk15on。我查看了生成的 .war 文件,WEB-INF 文件夹包含 jar。我尝试重新下载 maven 依赖项,在 eclipse 中做了一个项目清理和 maven 清理。

我还在 java.security 文件中添加了适当的行:

security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider

奇怪的是,我有时可以访问 ECPublicKeySpec。例如:

ECPublicKeySpec ecPublicKeySpec = new ECPublicKeySpec(point,
new ECParameterSpec(
curve.getCurve(),
curve.getG(),
curve.getN(),
curve.getH()));
logger.info(ecPublicKeySpec.toString());

上面的工作正常但是:

KeyFactory.getInstance("ECDSA").generatePublic(ecPublicKeySpec);

KeyFactory.getInstance("ECDSA", "BC").generatePublic(ecPublicKeySpec);

这不起作用并产生 NoClassDefFoundError。

编辑:忘记提及:如果我将我的应用程序部署到本地主机上的 tomcat,它就可以工作。如果我将它部署到远程 tomcat,它就无法工作。

EDIT2:mvn dependency:tree -Dverbose -Dincludes=org/bouncycaSTLe/jce/spec/ECPublicKeySpec 的输出:

[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'profiles' (position: START_TAG seen ...</profile>\n <profiles>... @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] ------------------------------------------------------------------------

最佳答案

就我而言,在 CentOS 上运行的远程 tomcat 服务器没有出现任何错误。但是,我在 Windows 10 上运行的本地环境中得到了 NoClassDefFoundError,尽管已经导入了相关的 maven 依赖项。幸运的是,除了maven依赖,将bcprov-jdk15on-1.55.jar文件复制到本地环境的$java_home/jre/lib/ext解决了问题。

关于java - NoClassDefFoundError : org/bouncycaSTLe/jce/spec/ECPublicKeySpec even though bouncycaSTLe is available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46664334/

54 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com