Intellij Idea 线程“main”出现异常java.lang.AssertionError

xxls0lw8  于 2023-04-19  发布在  Java
关注(0)|答案(6)|浏览(461)

在代码重构之后,当我尝试编译Maven项目时,我得到了这个错误:

"C:\Program Files\Java\jdk-14\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\plte1219\Desktop\CJM\media_auth -Xmx1024m -XX:MaxPermSize=512m "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\lib\idea_rt.jar=59675:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version2020.1.2 clean package
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< org.engine:engine_auth >-----------------------
[INFO] Building engine_auth 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ engine_auth ---
[INFO] Deleting C:\Users\plte1219\Desktop\CJM\media_auth\target
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ engine_auth ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 6 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ engine_auth ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 38 source files to C:\Users\plte1219\Desktop\CJM\media_auth\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.174 s
[INFO] Finished at: 2020-06-25T22:47:39+03:00
[INFO] ------------------------------------------------------------------------
---------------------------------------------------
constituent[0]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/conf/logging/
constituent[1]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/cdi-api-1.0.jar
constituent[2]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/commons-cli-1.4.jar
constituent[3]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/commons-io-2.5.jar
constituent[4]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/commons-lang3-3.8.1.jar
constituent[5]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/guava-25.1-android.jar
constituent[6]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/guice-4.2.1-no_aop.jar
constituent[7]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/jansi-1.17.1.jar
constituent[8]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/javax.inject-1.jar
constituent[9]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/jcl-over-slf4j-1.7.29.jar
constituent[10]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/jsoup-1.12.1.jar
constituent[11]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/jsr250-api-1.0.jar
constituent[12]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-artifact-3.6.3.jar
constituent[13]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-builder-support-3.6.3.jar
constituent[14]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-compat-3.6.3.jar
constituent[15]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-core-3.6.3.jar
constituent[16]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-embedder-3.6.3.jar
constituent[17]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-model-3.6.3.jar
constituent[18]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-model-builder-3.6.3.jar
constituent[19]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-plugin-api-3.6.3.jar
constituent[20]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-repository-metadata-3.6.3.jar
constituent[21]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-api-1.4.1.jar
constituent[22]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-connector-basic-1.4.1.jar
constituent[23]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-impl-1.4.1.jar
constituent[24]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-provider-3.6.3.jar
constituent[25]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-spi-1.4.1.jar
constituent[26]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-transport-wagon-1.4.1.jar
constituent[27]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-resolver-util-1.4.1.jar
constituent[28]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-settings-3.6.3.jar
constituent[29]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-settings-builder-3.6.3.jar
constituent[30]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-shared-utils-3.2.1.jar
constituent[31]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/maven-slf4j-provider-3.6.3.jar
constituent[32]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/org.eclipse.sisu.inject-0.3.4.jar
constituent[33]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/org.eclipse.sisu.plexus-0.3.4.jar
constituent[34]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/plexus-cipher-1.7.jar
constituent[35]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/plexus-component-annotations-2.1.0.jar
constituent[36]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/plexus-interpolation-1.25.jar
constituent[37]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/plexus-sec-dispatcher-1.4.jar
constituent[38]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/plexus-utils-3.2.1.jar
constituent[39]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/slf4j-api-1.7.29.jar
constituent[40]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/wagon-file-3.3.4.jar
constituent[41]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/wagon-http-3.3.4-shaded.jar
constituent[42]: file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202019.3.1/plugins/maven/lib/maven3/lib/wagon-provider-api-3.3.4.jar
---------------------------------------------------
Exception in thread "main" java.lang.AssertionError
    at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
    at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
    at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:836)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ImplicitCompleter.complete(JavacProcessingEnvironment.java:1588)
    at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:670)
    at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1383)
    at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.complete(Type.java:1157)
    at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.getTypeArguments(Type.java:1083)
    at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:237)
    at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:52)
    at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1010)
    at jdk.compiler/com.sun.tools.javac.code.Printer.visit(Printer.java:136)
    at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:199)
    at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167)
    at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
    at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
    at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:185)
    at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167)
    at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111)
    at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67)
    at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic.getMessage(JCDiagnostic.java:788)
    at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$DiagnosticSourceUnwrapper.getMessage(ClientCodeWrapper.java:835)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:131)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

我试图删除文件夹.m2,但问题没有解决。你知道我如何解决这个问题吗?

0x6upsns

0x6upsns1#

我也遇到了同样的问题。强制maven-compiler-plugin使用javac帮助我发现了实际的编译错误。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <forceJavacCompilerUse>true</forceJavacCompilerUse>
  </configuration>
</plugin>

更多细节可以在Maven Compiler Plugin bug report中找到

4szc88ey

4szc88ey2#

我在编译一个项目时遇到了这个非常无用的错误,发现问题是引用了另一个类中不存在的静态内部类(它已被重命名)。一旦解决了这个问题,错误就消失了。
解决方案:查找编译错误。有时IDE可以为您找到它们,而不会引发此错误。

r6l8ljro

r6l8ljro3#

恭喜你,你在Java编译器中发现了一个bug。这很罕见。这是一个编译器中的bug,因为类com.sun.tools.javac.util.Assert.error清楚地表明它来自javac,Java编译器,堆栈跟踪提供了关于如何重现这个bug的很好的提示。
请将bug报告给OpenJDK项目。有compiler-dev mailing list,您可以首先询问并联系OpenJDK项目的主要开发人员。
当你报告bug时,确保你可以可靠地重现bug,并尝试通过剥离任何不必要的代码以最简单的方式重现bug。通常情况下,你最终会得到一个最多包含5个文件的项目。Here's a guide for reporting good bugs

ix0qys7i

ix0qys7i4#

虽然我的回答有点晚了,但我想我的回答会对将来的人有所帮助。
我也面临着同样的问题,我发现的根本原因是
我更改了其中一个依赖项的代码,但没有更改该依赖项在pom.xml中的版本。
一旦我更新了两个pom.xml文件中的依赖项,一切就开始工作了。

i7uq4tfw

i7uq4tfw5#

我在重构后得到了这个错误,在我的例子中,崩溃是由导入一个不存在的类引起的。不幸的是,编译器和IDE没有意识到这个问题。
如果您按照@Yaroslav Buhaiev的建议启用forceJavacCompilerUse,您将看到更多有意义的错误。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile 
   (default-compile) on project reporting: Compilation failure: Compilation failure: 
[ERROR] /Users/myuser/projects/myproject//src/main/java/com/example/UserResource.java:[76,111] 
   error: cannot find symbol
[ERROR]   symbol:   variable MY_PARAM
[ERROR]   location: class UserRepository
2j4z5cfb

2j4z5cfb6#

使用下面的解决方案,我可以修复错误。
根本原因-特定模块内的config文件夹中存在不存在的bean类。
修复-从config文件夹中删除未使用的bean配置
示例-我从gateways模块中删除了一些类A,但bean配置仍然存在于config文件夹中。删除bean配置后,构建成功。
编辑器- IntelliJ Idea,JDK 11

相关问题