Elena
Elena

Reputation: 501

Liquibase maven plugin with JDK11 failing with ClassNotFoundException: XmlElement

I'm using Apache Maven 3.3.9 Java version: 11.0.5 And the latest version of liquibase-maven-plugin as follows:

           <plugin>
              <groupId>org.liquibase</groupId>
              <artifactId>liquibase-maven-plugin</artifactId>
              <configuration>
                 <changeLogFile>src\main\resources\changelog.yaml</changeLogFile>
                 <driver>oracle.jdbc.OracleDriver</driver>
                 <url>thin_url</url>
                 <username>user</username>
                 <password>password</password>
              </configuration>
           </plugin>        

I've added in my poml.xml the following dependencies

<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.3.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-core</artifactId>
  <version>2.3.0.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.3.1</version>
</dependency>

but each time execute the plugin with mvn liquibase:update I've got an Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlElement exception.

Any clue what I'm doing wrong?

Upvotes: 1

Views: 3378

Answers (2)

Elena
Elena

Reputation: 501

I was adding the dependencies in the wrong place. I was adding them as 'regular' dependencies in the pom. I didn't know that I had to add them in the plugin as follows:

       <plugin>
          <groupId>org.liquibase</groupId>
          <artifactId>liquibase-maven-plugin</artifactId>
          <version>${liquibase.version}</version>
          <configuration>
             <changeLogFile>resources\changelog2.yml</changeLogFile>
             <driver>oracle.jdbc.OracleDriver</driver>
             <url>url</url>
             <username>user</username>
             <password>password</password>
             <verbose>true</verbose>
          </configuration>
           <dependencies>
            <dependency>
                <groupId>jakarta.xml.bind</groupId>
                <artifactId>jakarta.xml.bind-api</artifactId>
                <version>2.3.2</version>
            </dependency>
          </dependencies>
       </plugin>        

Upvotes: 4

SteveDonie
SteveDonie

Reputation: 9016

Java 9 (and above) removed some classes that used to be part of the standard Java runtime.

See this question and answer for more details: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

Upvotes: 0

Related Questions