1

I am trying to run "mvn clean install" command, but I get the following error:

java:[42,22] package javax.xml.bind does not exist

Do you have any idea why?

Ana
  • 93
  • 1
  • 2
  • 7
  • The question doesn't match the description. "javax.xml.bind" and "javax.xml.bind.annotation" are different packages, and the answers are not interchangeable. – Graham Leggett Jul 09 '23 at 09:37

3 Answers3

5

Try adding

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

into your pom.xml file

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • 1
    and after adding should I directly retry running the mvn clean install command? – Ana Aug 23 '21 at 12:30
  • Sure. Possibly you will have to add more dependencies and some more setting. You did not present your pom.xml and other essential settings – Prophet Aug 23 '21 at 13:13
  • and I had to do this as well otherwise my test was failing `mvn clean install -DskipTests`... I'm not a java developer so I don't know if skipping these tests were a good idea. – Ameer Ul Islam Apr 10 '22 at 19:46
3

The library javax.xml.bind has been removed from Java 11 release.
Release Notes
For fixing this you have add those dependencies explicitly in your POM file or add it to your classpath accordingly.

<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.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.3.1</version>
</dependency>

After adding it to your POM you can build the maven project. First time you can skip tests.

mvn clean install -DskipTests
TriS
  • 3,668
  • 3
  • 11
  • 25
0

Download jaxb API jar file, and add it as an external jar to the Java build path.

epithite32
  • 59
  • 4