I have a multi-module application which has a java HTTP application (springboot, java 11) in one module and scala code in the second module.
The second module is included as a dependency in the first module as code in the second module needs to get invoked on REST invocations.
Here is a minimal project to reproduce the issue.
Steps to reproduce the issue
mvn clean compile
java -jar scala-compiler-issue-service/target/scala-compiler-issue-service-1.0-SNAPSHOT.jar
The above command to run the application fails on initialisation of the scala compiler.
Caused by: scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:24) ~[scala-reflect-2.12.16.jar!/:na]
at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:25) ~[scala-reflect-2.12.16.jar!/:na]
at scala.reflect.internal.Mirrors$RootsBase.$anonfun$getModuleOrClass$5(Mirrors.scala:61) ~[scala-reflect-2.12.16.jar!/:na]
at scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:61) ~[scala-reflect-2.12.16.jar!/:na]
Interesting thing here is once we run the application using -cp command and pass the scala jars in classpath then the initialisation does not fail
java -cp scala-compiler-issue-service/target/scala-compiler-issue-service-1.0-SNAPSHOT.jar:scala-reflect-2.12.16.jar:scala-compiler-2.12.16.jar:scala-library-2.12.16.jar -Dloader.main=org.example.ServiceAPIApplication org.springframework.boot.loader.PropertiesLauncher
The 3 scala jars used are included in the project. They are fetched from maven repository using
wget https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.16/scala-reflect-2.12.16.jar
wget https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.16/scala-library-2.12.16.jar
wget https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.16/scala-compiler-2.12.16.jar
Comment From: bclozel
Thanks for getting in touch, but this looks like a build configuration issue that's specific to Scala and it's not clear why you're considering this a Spring Boot bug. Additionally, Spring Boot 2.6.x is out of open source support.
Please consider first asking a question on StackOverflow and report back here if you're getting more information suggesting that this is a Spring Boot bug for a supported version.