0

What is the difference between the two packages of the same json-b spec? Why Yasson uses the Jarkata version rather than the javax one?

If I include the javax version as compile-scope dependency and Yasson as runtime-scope,

        <dependency>
            <groupId>javax.json.bind</groupId>
            <artifactId>javax.json.bind-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse</groupId>
            <artifactId>yasson</artifactId>
            <version>3.0.3</version>
            <scope>runtime</scope>
        </dependency>

then, using JDK 11, I get ClassCastException at runtime:

Jsonb JSON Binding provider org.eclipse.yasson.JsonBindingProvider could not be instantiated: java.lang.ClassCastException: class org.eclipse.yasson.JsonBindingProvider cannot be cast to class javax.json.bind.spi.JsonbProvider (org.eclipse.yasson.JsonBindingProvider and javax.json.bind.spi.JsonbProvider are in unnamed module of loader 'app')

q3769
  • 192
  • 1
  • 12

1 Answers1

1

To answer my own question after googling...

The "EE" stack is now owned by Eclipse rather than Oracle. As such,

the Eclipse Foundation can't create any new Java packages using the javax namespace, but it can create new classes and subclasses under the existing ones.

I guess that's the reason for repackaging the Oracle-owned "javax" namespace into "jakarta".

Link to the info source article: https://www.baeldung.com/java-enterprise-evolution

q3769
  • 192
  • 1
  • 12