2

I try to migrate my java8 spring project to java11. Now I get the following exception when I try to run it from eclipse:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules java.activation and jakarta.activation export package javax.activation to module spring.boot.starter.web

Under Referenced Libraries I only found jakarta.activation-api-1.2.2.jar which exports the package javax.activation. The other module java.activation I have no clue where it comes from. From the name it should be inside JavaSE-11/JDK ? I checked the entry JRE System Library but I don't see that package there.

Now the curios thing is with Gradle 6.5 I can run the project using "gradlew bootRun" and it executes nicely. However in eclipse it fails with the errror.

So in eclipse I just tried to remove Jakarta.activation by Right-click remove from build path. Trying to import anything from javax.activation then gives me "import can't be resolved", fine so far. However running still complains with the above ResolutionException.

So to fix the issue:

  • Where is the other sourcecode that exports javax.activation package? And how do I find that?
  • How can I prevent eclipse from having those two modules at runtime?
  • Can I exclude the module in gradle, such that the project works after running "gradlew eclipse" like always?

Thanks for your help! I spent hours searching and didn't find anything useful so far.

The build.gradle looks as following:


plugins {
    id 'org.springframework.boot' version '2.2.5.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
    id 'eclipse'
}

group = 'example'
version = '0.3.0'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
    mavenCentral()
}

configurations.all {
    // fix multiple slf4j dependencies are present
    exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    //TODO: 1st approach to fix ResolutionException
    //exclude group: 'jakarta.activation', module: 'jakarta.activation-api'
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:2.3.1.RELEASE'
    implementation ('org.springframework.boot:spring-boot-starter-web:2.3.1.RELEASE') {
        //TODO: 2nd approach to fix ResolutionException
        exclude group: 'jakarta.activation', module: 'jakarta.activation-api'
    }
    implementation 'org.springframework.boot:spring-boot-starter-security:2.3.1.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.3.1.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-actuator:2.3.1.RELEASE'
    implementation 'mysql:mysql-connector-java:5.1.46'
    implementation 'com.querydsl:querydsl-jpa:4.1.4'
    implementation 'com.querydsl:querydsl-apt:4.1.4:jpa'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'org.flywaydb:flyway-core:5.2.4'
    compileOnly 'org.springframework.boot:spring-boot-devtools:2.3.1.RELEASE'

    // https://mvnrepository.com/artifact/org.apache.odftoolkit/simple-odf
    implementation 'org.apache.odftoolkit:simple-odf:0.8.2-incubating'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-text
    implementation 'org.apache.commons:commons-text:1.1'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
    implementation 'org.apache.commons:commons-lang3:3.7'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-csv
    implementation 'org.apache.commons:commons-csv:1.5'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.3
    implementation 'org.apache.commons:commons-collections4:4.3'

    implementation 'javax.validation:validation-api:2.0.0.Final'
    // Dependencies that are no longer in java11
    // implementation 'javax.xml.bind:jaxb-api:2.3.0'
    // implementation 'com.sun.xml.bind:jaxb-core:2.3.0'
    // implementation 'com.sun.xml.bind:jaxb-impl:2.3.0'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
    testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.2'

}

eclipse {
    classpath {
        downloadJavadoc = true
        downloadSources = true
    }
}

Other links I found but didn't help me so far:

judos
  • 445
  • 4
  • 14

1 Answers1

0

Ok I found part of an answer while trying to create an example to reproduce the issue.

First I tried to clean the project to make sure nothing bad is cached in eclipse:

gradlew clean eclipse

Still the problem occured.

Now I went full ham and removed all build files, .project, .classpath and reran gradlew eclipse and while adding a new run configuration the project now starts fine. So probably blame the cache of the run-configuration.

Maybe this or the cross-links to other posts about the same issue still helps someone.

judos
  • 445
  • 4
  • 14