Maven is not able to find jaxb-api with OpenJDK 11 even though its present in the repository

Ishan Rastogi :

I have a machine having Windows OS, it is used to build few WAR Projects. It has Java 8 installed on it. I am using Maven 3.2.5 to build these WAR Projects. Everything is working fine. But as Java 8 will be a problem in future due to its end of free updates I thought of upgrading to OpenJDK 11.

I downloaded OpenJDK 11 but did not install it as I just wanted to try this for 1 of the project to start. I picked up one of the WAR Project to check if OpenJDK 11 works. This project is created using JHipster and Spring Boot. I changed the pom.xml for this project to use spring-boot.version to 2.1.2 and java.verion to 11 and also put the jaxb-api, jaxb-impl, jaxb-runtime and javax.activation enteries(as shown below) to avoid jaxb related dependency errors in Java 11.

In windows command prompt, I set the JAVA_HOME and PATH variables to OpenJDK11 and then I fire the mvn clean compile package command. As expected all jaxb related dependencies are downloaded in the maven repository but still maven is throwing error NoClassDefFoundError: javax/xml/bind/JAXBException while jaxb-api jar is still there in Maven repository. I tried to fire the command again but no luck.

Can anyone please guide me about the possible root cause or any workaround.

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
Simon :

I got this working with the following POM

<properties>
    <maven-jaxb2-plugin.version>0.14.0</maven-jaxb2-plugin.version>
</properties>

//

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.4.0-b180830.0359</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.0-b170127.1453</version>
    </dependency>
</dependencies>

//

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${maven-jaxb2-plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
            </configuration>
        </plugin>
    </plugins>
</build>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=152771&siteId=1