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?

2 Answers 2

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>        
1
  • I don't think the dependencies->dependency nesting is correct. Intellij gives an error that "artifactId" is expected without those tags
    – Alkanshel
    Apr 11 at 21:12
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

1
  • 2
    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, 2019 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.