"/packages cannot be represented as URI"
Asked Answered
C

4

0

I am working on a Scala project that use maven POM.xml file to build.

the build failed after adding test file that import "org.scalatest.FunSuite" or "...Matchers" with error message "/packages cannot be represented as URI"

plugin "scalatest-maven-plugin" is in used in the pom.xml but works file as long as there is no FunSuite or Matchers is imported

the test dependency in the pom looks like this

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
            <version>3.0.5</version>
            <scope>test</scope>
        </dependency>

scala version: 2.12.7

maven version: 3.8.6

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home

Canto answered 20/8, 2022 at 17:39 Comment(2)
Have you set java properly in your project? like in intellij's project structure? or an appropriate java home? – Airedale
@Airedale yes it was fix from project structure, because of IntelliJ IDE use the JDK defined there not of the HOME_JAVA – Canto
C
2

Found the solution:

The Project Build of IntelliJ doesn't really care about the path of JDK in env var JAVA_HOME, it takes the one from project settings, so to solve this I have to:

  • go to File -> Project Structure (Command + ;)
  • On the left select Project Settings, Modules
  • Select the module and from Module SDK drop list pick one of the compatible SDK like:
  • jdk1.8.0_202 or jdk1.8.0_251, correto1.8 or AdoptOpenJDK 1.8, ....
  • The ones that does NOT work with me are:
  • jbr17, correto16, temurin-17, ...

enter image description here

Canto answered 21/8, 2022 at 9:6 Comment(1)
That's great that you were able to fix it by ensuring you were on Java 8, but note that you should be able to use JDK 17 if your tooling (language, build tool & plugins) is on current versions. – Prickett
C
4

This is a Scala compiler bug. Please upgrade to the latest Scala point release, 2.12.16.

Categorize answered 21/8, 2022 at 18:11 Comment(1)
You'r right, I have test it, when using scala version 2.12.16 I can build with all JDK version πŸ‘πŸΌ – Canto
C
2

Found the solution:

The Project Build of IntelliJ doesn't really care about the path of JDK in env var JAVA_HOME, it takes the one from project settings, so to solve this I have to:

  • go to File -> Project Structure (Command + ;)
  • On the left select Project Settings, Modules
  • Select the module and from Module SDK drop list pick one of the compatible SDK like:
  • jdk1.8.0_202 or jdk1.8.0_251, correto1.8 or AdoptOpenJDK 1.8, ....
  • The ones that does NOT work with me are:
  • jbr17, correto16, temurin-17, ...

enter image description here

Canto answered 21/8, 2022 at 9:6 Comment(1)
That's great that you were able to fix it by ensuring you were on Java 8, but note that you should be able to use JDK 17 if your tooling (language, build tool & plugins) is on current versions. – Prickett
L
1

If you're using intelliJ

  • Go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> sbt
  • Make sure Use sbt shell for build is checked
Lizzettelizzie answered 19/1, 2023 at 8:48 Comment(0)
A
0

In My Case I had resolved this issue by installing a java version of 1.8 and set JAVA_HOME to this version.

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home"

Arsenious answered 20/8, 2022 at 17:45 Comment(2)
I download it and use it, but still have same error – Canto
Both version were compatible, but the problem was in the setting of intelliJ – Canto

© 2022 - 2024 β€” McMap. All rights reserved.