BeanInstantiationException: Failed to instantiate [javax.xml.bind.Unmarshaller]: Java 11

December 24, 2018

                With Java 11, java.xml.bind package is removed from JDK library.

  This proposal assumes that developers who wish to compile or run applications on the latest JDK can find   and deploy alternate versions of the Java EE technologies. The Reference Implementations (RIs) of JAX-WS   and JAXB are a good starting point because they are complete replacements for the java.xml.ws and        java.xml.bind modules in JDK 9.

 

 The RIs are available as Maven artifacts: (note that they must be deployed on the class path).

 

  com.sun.xml.ws : jaxws-ri (JAX-WS, plus SAAJ and Web Services Metadata)

  com.sun.xml.bind : jaxb-ri (JAXB)

 The tools for JAX-WS and JAXB are also available as Maven artifacts:

There are also Maven artifacts that contain just the APIs of the Java EE technologies:

This issue can be resolved by adding the below dependency directly to pom.xml or build.gradle

Maven

Exception: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.xml.bind.Unmarshaller]: Factory method 'xxxxxx' threw exception; nested exception is javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath or package javax.xml.bind does not exist.

Exception: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.xml.bind.Unmarshaller]: Factory method 'xxxxxx' threw exception; nested exception is javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath or package javax.xml.bind does not exist.

    <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</version>

    </dependency>

      <dependency>

         <groupId>com.sun.xml.bind</groupId>

         <artifactId>jaxb-impl</artifactId>

         <version>2.3.1</version>

    </dependency>

    compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'

    compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'

    compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.1'

   Gradle

© DevClassRoom

  • Facebook Black Round
  • Google+ - Black Circle
  • Twitter Black Round