New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 9 Spring Boot application build throws RuntimeException using Maven #10647

Closed
techpavan opened this Issue Oct 16, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@techpavan

techpavan commented Oct 16, 2017

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

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll Oct 16, 2017

Member

@techpavan thanks a lot for the detailed analysis!

Member

snicoll commented Oct 16, 2017

@techpavan thanks a lot for the detailed analysis!

@wilkinsona

This comment has been minimized.

Show comment
Hide comment
@wilkinsona

wilkinsona Oct 16, 2017

Member

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.

Member

wilkinsona commented Oct 16, 2017

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.

@techpavan

This comment has been minimized.

Show comment
Hide comment
@techpavan

techpavan Oct 17, 2017

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.

techpavan commented Oct 17, 2017

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.

@snicoll snicoll self-assigned this Oct 17, 2017

@snicoll snicoll closed this in dd90f07 Oct 17, 2017

kristines pushed a commit to accso/java9-jigsaw-examples that referenced this issue Oct 30, 2017

kristines
A few steps towards beeing able to run our application as module:
* Explicitely added main class. This avoids letting sprin boot search
a main class itself which let to an asm problem. See spring-projects/spring-boot#10647
* Added CLI args --add-modules java.xml.bind in spring-boot:run plugin
Now failing with java.io.IOException: invalid constant type: 19 at 6.
Seems to be a known javassist problem. See https://stackoverflow.com/questions/46132019/java-io-ioexception-invalid-constant-type-19-at-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment