0

I have a simple project that creates XML file from POJOs. It works fine with javax dependencies(2.x), since javax.xml packages removed in Java 11, I switched to Jakarta packages. When I run the project I get the error:

java.lang.NoClassDefFoundError: jakarta.activation.DataSource

pom.xml

        <!-- JAXB API -->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>3.0.1</version>
        </dependency>


        <!-- JAXB RI, Jakarta XML Binding -->
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>3.0.1</version>
            <scope>runtime</scope>
        </dependency>

uploaded source code to Github repository for reference

andrewJames
  • 19,570
  • 8
  • 19
  • 51
Pavan Jadda
  • 4,306
  • 9
  • 47
  • 79
  • 1
    Use the `javax.xml` one not the jakarta one. The packages changed for those and that won't work with Spring. – M. Deinum Jun 30 '21 at 06:55
  • note; in Apache Tomcat server since version 9 and many other Java packages for other projects everything has become part of the Jakarta project because Oracle has tightened down on the licensing of "javax" packages in Java. https://eclipse-ee4j.github.io/jaf/ (javax.activation)"Java Activation Framework" now must be (jakarta.activation)"Jakarta Activation Framework" – Samuel Marchant Jun 30 '21 at 08:16
  • @M.Deinum but that was deprecated and no longer supported. – Pavan Jadda Jun 30 '21 at 13:54
  • No it wasn't. The version with the JDK was deprecated NOT the external one (that is quite a difference). The Jakarta one is from JakartaEE **not** JavaEE and simply isn't supported by Spring (and many other frameworks) due to package and dependency changes. – M. Deinum Jun 30 '21 at 13:59
  • @M.Deinum If you are referring to this https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api and I am currently using this. It got no updates since October 2018 – Pavan Jadda Jun 30 '21 at 14:07
  • The fact that it has no updates, doesn't mean it is deprecated. – M. Deinum Jun 30 '21 at 14:09
  • @M.Deinum based what I read online, it was part of the Java 8, deprecated in Java 9 and removed in Java 11. – Pavan Jadda Jun 30 '21 at 14:33
  • Again as stated the one that was part of the JVM, **not** the external one. It was deprecated as part of the JVM. – M. Deinum Jun 30 '21 at 14:37
  • @M.Deinum Do you have a link for external one? I can't seem to find it – Pavan Jadda Jun 30 '21 at 15:07
  • 1
    The JEP itself for removal out of the JDK, nonetheless fact remains that spring simply cannot work with the Jakarta based apis as they simply not support it. – M. Deinum Jul 01 '21 at 05:03
  • Check [this question](https://stackoverflow.com/q/53978612/6413377). As M. Deinum already wrote few times these libraries just were removed from standard JVM delivery not deprecated anyway. – pirho Jul 01 '21 at 17:54

0 Answers0