1

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?

Chei
  • 2,117
  • 3
  • 20
  • 33
Elena
  • 501
  • 1
  • 6
  • 15

2 Answers2

4

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>        
Elena
  • 501
  • 1
  • 6
  • 15
0

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

SteveDonie
  • 8,700
  • 3
  • 43
  • 43
  • 1
    I already saw that link and that is why I added the dependencies to the pom.xml. I did a test, even including the jakarta, glassfish, etc.. dependencies mentioned in the link and it's not working. From what I've read in that link, it should be enough, but it's not. – Elena Nov 22 '19 at 09:12