0

I am running a Spring Boot project. I can run the project from IntelliJ, however when I try and do mvn spring-boot:run I get java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I have included

<dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
</dependency>

in my pom.xml file. I have even included java.xml.bind as an add modules in the pom. But the issue still persists. What am I missing?

MaxPower
  • 881
  • 1
  • 8
  • 25
  • Class not found is `javax/xml/bind/JAXBException` and is not from `com.sun.xml.bind` which you are trying to add. Which version of java are you running from command line? – jny Feb 27 '18 at 20:46
  • I am running Java 9 – MaxPower Feb 27 '18 at 20:46
  • Possible duplicate: https://stackoverflow.com/questions/26413431/which-artifacts-should-i-use-for-jaxb-ri-in-my-maven-project – lexicore Feb 27 '18 at 20:46
  • 1
    Take a look at https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j. The dependency suggested there is: ` javax.xml.bind jaxb-api 2.3.0 ` – jny Feb 27 '18 at 20:48

1 Answers1

0

Credit to @jny for the answer

I had the wrong dependency in the pom file. Replacing it with

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

corrected the issue.

MaxPower
  • 881
  • 1
  • 8
  • 25