Spring boot maven plugin is throwing RuntimeException during build for a Java 9 application. The issue occurs at org.springframework.asm.ClassVisitor:148 due to the api version used as ASM4. This api version is configured in the child class located at org.springframework.boot.loader.tools.MainClassFinder:301. Below are some of the details, please let me know if more is needed.
Maven Version: 3.5.0
Spring Boot: 2.0.0.M5
Java: 9 (build 9+181)
Discussion Thread: https://stackoverflow.com/questions/46744154/runtimeexception-during-maven-build-of-java-9-spring-boot-application
Reproducer: https://github.com/techpavan/java9-maven-spring-boot
Stacktrace:
Caused by: java.lang.RuntimeException
at org.springframework.asm.ClassVisitor.visitModule(ClassVisitor.java:148)
at org.springframework.asm.ClassReader.readModule(ClassReader.java:762)
at org.springframework.asm.ClassReader.accept(ClassReader.java:663)
at org.springframework.asm.ClassReader.accept(ClassReader.java:527)
at org.springframework.boot.loader.tools.MainClassFinder.createClassDescriptor(MainClassFinder.java:267)
at org.springframework.boot.loader.tools.MainClassFinder.doWithMainClasses(MainClassFinder.java:223)
at org.springframework.boot.loader.tools.MainClassFinder.findSingleMainClass(MainClassFinder.java:203)
at org.springframework.boot.loader.tools.Repackager.findMainMethod(Repackager.java:365)
at org.springframework.boot.loader.tools.Repackager.findMainMethodWithTimeoutWarning(Repackager.java:354)
at org.springframework.boot.loader.tools.Repackager.buildManifest(Repackager.java:325)
at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:255)
at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:248)
at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:193)
at org.springframework.boot.maven.RepackageMojo.repackage(RepackageMojo.java:221)
at org.springframework.boot.maven.RepackageMojo.execute(RepackageMojo.java:208)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 22 more
@techpavan thanks a lot for the detailed analysis!
This only occurs with module-info.java
in place. It also doesn't occur if you explicitly declare the main class:
diff --git a/pom.xml b/pom.xml
index 731b131..e2bd6ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,6 +83,9 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>com.test.TestMain</mainClass>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
There are plenty of other potential problems that you may hit with Java 9 in module mode, many due to split packages in libraries in the Java ecosystem. You want want to stick with class path mode until things have had a chance to settle down.
Ideally its a good thing if all our dependencies are modularized, but reality just ensures the popular ones to support Java 9. For the current case, I worked around with mainClass configuration and its working as expected.
Most helpful comment
This only occurs with
module-info.java
in place. It also doesn't occur if you explicitly declare the main class:There are plenty of other potential problems that you may hit with Java 9 in module mode, many due to split packages in libraries in the Java ecosystem. You want want to stick with class path mode until things have had a chance to settle down.