java.lang.RuntimeException:com.sun.tools.javac.code.Symbol$CompletionFailure:未找到 org.bouncycastle.asn1.DERInteger 的 class 文件

java.lang.RuntimeException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.bouncycastle.asn1.DERInteger not found

我正在打开一个用 Java EE 7 编写的先前应用程序。我的目标是编译和 运行 该应用程序。我已经尝试了多种 Netbeans 和操作系统来完成这项工作。该应用程序在使用 Netbeans 11.3 的独立 Macbook Pro 笔记本电脑中编译并且 运行 运行良好。 Mac 仅用于测试。

服务器环境是 Windows 2019 服务器 (v1809),这是我在使用 Netbeans v11.3 和 12.0 时遇到问题的地方。在这两种情况下,我都会遇到同样的错误。我还尝试在 JDK 1.7 和 1.8 中构建。注意到堆栈跟踪中的 CanonialModelProcessor 消息,我正在构建 JDK 1.8.

Compiling 203 source files to C:***\build\web\WEB-INF\classes warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.8' Note: Creating static metadata factory ... error: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.bouncycastle.asn1.DERInteger not found

An annotation processor threw an uncaught exception. Consult the following stack trace for details. java.lang.RuntimeException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.bouncycastle.asn1.DERInteger not found at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:407) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access00(JavacProcessingEnvironment.java:91) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856) at com.sun.tools.javac.main.Main.compile(Main.java:523) at com.sun.tools.javac.main.Main.compile(Main.java:381) at com.sun.tools.javac.main.Main.compile(Main.java:370) at com.sun.tools.javac.main.Main.compile(Main.java:361) at com.sun.tools.javac.Main.compile(Main.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57) at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1404) at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1133) at org.netbeans.modules.java.source.ant.JavacTask.execute(JavacTask.java:120) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at java.util.Vector.forEach(Vector.java:1275) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at org.apache.tools.ant.Target.execute(Target.java:449) at org.apache.tools.ant.Target.performTasks(Target.java:470) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388) at org.apache.tools.ant.Project.executeTarget(Project.java:1361) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:261) at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:574) at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:128) Caused by: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.bouncycastle.asn1.DERInteger not found BUILD FAILED (total time: 10 seconds)

我在 SOF 和其他在线资源上研究了一些类似的问题。我注意到 bouncycastle 图书馆往往位于多个地方。我的问题是:

  1. 如果这真的是一个关于 bouncycastle 的错误,是否有一个包含所有 bouncycastle 类 的库?在我的应用程序中,我添加了:

     lib\bcpkix-jdk15to18-168.jar lib\bcprov-ext-jdk15to18-1.68.jar
     lib\bcprov-jdk15on-1.68.jar lib\bc-fips-1.0.2.jar
     lib\bcmail-fips-1.0.3.jar lib\bcpkix-fips-1.0.5.jar
     lib\bcpkix-jdk15to18-168.jar
    
  2. 如果不是 bouncycastle 错误,知道是什么原因造成的吗?

非常感谢!

我通过反复试验将其重建为 Maven 项目解决了这个问题,主要是导入最新/更新的依赖项。在观察到编译错误的情况下,通过导入与最初编写应用程序时的关闭时间戳相匹配的依赖项来解决此问题。