0

I have an Spring Boot App which runs on Java 8.

When deploying the app on tomcat which is on server, following error occurs when the app starts:

ClassNotFoundException: javax.xml.bind.JAXBException

As i read on Stackoverflow and other sites this error has to do with java 9+...but I am using java 8!

UPDATE: Please see my included dependencies below:.................................

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <!-- 
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    -->
    <!-- 
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>2.0.6</version>
    </dependency>
    -->

    <!-- Monitoring -->
    <dependency>
        <groupId>net.bull.javamelody</groupId>
        <artifactId>javamelody-spring-boot-starter</artifactId>
        <version>1.81.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.module</groupId>
        <artifactId>jackson-module-parameter-names</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jdk8</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180813</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security.oauth</groupId>
        <artifactId>spring-security-oauth2</artifactId>
        <version>2.3.4.RELEASE</version>
    </dependency>   

    <!-- Swagger 2 -->
     <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>  

    <!-- for Testing -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
skm
  • 559
  • 1
  • 6
  • 22
  • Import that class – MZ97 Feb 21 '20 at 08:18
  • And the solution? – skm Feb 21 '20 at 08:18
  • Possibly duplicate of https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j – Amit Chudasama Feb 21 '20 at 08:24
  • 1
    Why duplicate?? your Link talks about Java 9 and I am talking about Java 8! – skm Feb 21 '20 at 08:25
  • Do you have this piece of code inside your code? `libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.0"` – MZ97 Feb 21 '20 at 08:25
  • No. Kindly see my dependencies in my updates answer. – skm Feb 21 '20 at 08:32
  • Please check this for dependecies: [Page](https://www.studytonight.com/post/solved-javalangnoclassdeffounderror-javaxxmlbindjaxbexception-in-java-11) It should work for Java 8 too – MZ97 Feb 21 '20 at 08:36
  • @MZ97 tried including this dependency...but other exceptions occured then : NullPointer at somewhere... Other idea? – skm Feb 21 '20 at 09:41
  • Are you sure that is not coming from other parts of the cdoe? – MZ97 Feb 21 '20 at 10:23
  • just had to restart tomcat on server...very strange... – skm Feb 22 '20 at 15:35
  • 1
    @skm Also the same situation: `Java 8` + `NoClassDefFoundError: javax/xml/bind/JAXBException`. Just restarting the Tomcat server fixes it. – tom_mai78101 Nov 19 '21 at 16:09
  • Just to add. Tomcat server needs to start up with `Java 8`. You can see this at the beginning of the `catalina.out` output log file. – tom_mai78101 Nov 19 '21 at 16:19

0 Answers0