1

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

Passing the jars via classpath solves this issues but is causing problems in other parts of the application

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.