Unable to load class 'jakarta.xml.bind.ValidationEventLocator'

Viewed 392

I get the error "Execution failed for task :genJaxb, Unable to load class 'jakarta.xml.bind.ValidationEventLocator'." when I try to build my project with Gradle 7.3. I use Spring Boot 2.6.2,Java 11 and use Intellij as IDE. I read in several pages to add few dependencies (jaxb-impl,jaxb-core,jaxb-bind) and the problem should be solved, but nothing has been solved 'till now. Beside the mentioned jaxb dependencies , I also tried many other dependencies, nothing works. I should also mention that this occurs since I upgraded Spring boot to version 2.6.2. I don't know what I am doing wrong.

My build.gradle file looks as the following:

buildscript {
dependencies {
    //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
    classpath 'net.researchgate:gradle-release:2.8.1'


}

ext {
    springVersion = '2.6.2'
}

repositories {
    mavenCentral {
        url "https://artifactory.com/artifactory/libs-release"
    }
}

dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.2")
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0"
}

}

task genJaxb {
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
//ext.sourcesDir = "src/main/java"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schema = "src/main/resources/......"

outputs.dir classesDir

doLast() {
    project.ant {
        taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask", classpath: configurations.jaxb.asPath
        mkdir(dir: sourcesDir)
        mkdir(dir: classesDir)

        xjc(destdir: sourcesDir, schema: schema,
                package: "com........") {
            arg(value: "-wsdl")
            produces(dir: sourcesDir, includes: "**/*.java")
        }

        javac(destdir: classesDir, debug: true, debugLevel: "lines,vars,source", classpath: configurations.jaxb.asPath) {
            src(path: sourcesDir)
            include(name: "**/*.java")
            include(name: "*.java")
        }

        copy(todir: classesDir) {
            fileset(dir: sourcesDir, erroronmissingdir: false) {
                exclude(name: "**/*.java")
            }
        }
    }
}

}

group = "${groupName}"
version = "${buildVersion}"


dependencies {
implementation "org.springframework.boot:spring-boot-starter-web:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-actuator:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-security:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-ldap:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-tomcat:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-web-services:2.6.2"  // 2.1.1 can't compile
implementation group: 'org.springframework.boot', name: 'spring-boot-devtools', version: "${springVersion}"
implementation group: 'org.springframework.boot', name: 'spring-boot', version: '2.6.2'
implementation group: 'io.micrometer', name: 'micrometer-core', version: '1.8.1'
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.8.1'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
implementation 'com.sun.xml.bind:jaxb-core:3.0.1'
implementation 'javax.xml.soap:javax.xml.soap-api:1.4.0'
implementation 'javax.xml.soap:saaj-api:1.3.5'
implementation 'com.sun.xml.messaging.saaj:saaj-impl:2.0.1'
implementation 'org.springframework.boot:spring-boot-starter-log4j:1.3.8.RELEASE'

implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.1'

implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.4'
implementation group: 'javax.mail', name: 'mail', version: '1.4.7'
 implementation(files(genJaxb.classesDir).builtBy(genJaxb))

jaxb 'com.sun.xml.bind:jaxb-xjc:3.0.1'
implementation group: 'org.snmp4j', name: 'snmp4j', version: '2.6.3'
implementation group: 'org.snmp4j', name: 'snmp4j-agent', version: '2.6.3'
implementation group: 'org.apache.xmlrpc', name: 'xmlrpc-client', version: '3.1.3'
implementation files('lib/jmon-2.3.jar')
implementation group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: '2.6.0'
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
implementation 'org.springframework.boot:spring-boot-properties-migrator:2.6.2'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.2'
implementation group: 'javax.xml.bind', name: 'jaxb-api-osgi', version: '2.2'
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359'
implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '3.0.2'
implementation group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.1'
implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '3.0.1'

}

Also this error is written:

Task :genJaxb FAILED [ant:xjc] [WARNING] Versuchen Sie, WSDL zu kompilieren? Unterst�tzung f�r WSDL ist zu Testzwecken bestimmt. Eine Aktivierung ist mit der Option -wsdl m�glich. [ant:xjc] unbekanntes Verzeichnis [ant:xjc]

Obviously he has some problem with the xjc task in genJaxb.

Thanks in advance.

0 Answers
Related