Provider org.glassfish.json.JsonProviderImpl not found at javax.json.spi.JsonProvider.provider(JsonProvider.java:97)

33,703

You're developing against an API and have no implementation for that API. You need to make sure you have an implementation of the JSON-P specification to actually run the code you're trying to use.

In the JSR 374 official website Getting Started guide, it shows that you need two Maven dependencies - one for the API and one for the reference implementation - before you can use JSON-P 1.1:

<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <version>1.1</version>
</dependency>

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.1</version>
</dependency>

Since it looks like you're not using Maven, you will need to download the implementation JAR from Maven Central manually: https://repo1.maven.org/maven2/org/glassfish/javax.json/1.1/

Or just click this direct link to download the JAR: javax.json-1.1.jar

Share:
33,703

Related videos on Youtube

Shaurya Manhar
Author by

Shaurya Manhar

Updated on April 19, 2020

Comments

  • Shaurya Manhar
    Shaurya Manhar about 4 years

    How to run Java API for JSON Processing(JSR 374) in eclipse?

    I am trying to parse JSON string to JsonParser(javax.json.stream.JsonParser). Also added javax.json-api-1.0.jar in the build path. At runtime, there is an exception. My code is

    import java.io.StringReader;
    import javax.json.Json;
    import javax.json.JsonReader;
    import javax.json.JsonStructure;
    import javax.json.stream.JsonParser;
    import javax.json.stream.JsonParser.Event;
    import javax.json.JsonReader;
    import javax.json.JsonStructure;
    import javax.json.stream.JsonParser;
    import javax.json.stream.JsonParser.Event;
    public class jsonnn {
    public class jsonnn {
    public static void main(String[] args) {
            // Parse back
            final String result = "{\"name\":\"Falco\",\"age\":3,\"bitable\":false}";
            final JsonParser parser = Json.createParser(new StringReader(result));
            String key = null;
            String value = null;
            while (parser.hasNext()) {
                final Event event = parser.next();
                switch (event) {
                case KEY_NAME:
                    key = parser.getString();
                    System.out.println(key);
                    break;
                case VALUE_STRING:
                    value = parser.getString();
                    System.out.println(value);
                    break;
                }
            }
            parser.close();
        }
    }
    

    And the exception is

    Exception in thread "main" javax.json.JsonException: Provider org.glassfish.json.JsonProviderImpl not found
    at javax.json.spi.JsonProvider.provider(JsonProvider.java:97)
    at javax.json.Json.createParser(Json.java:90)
    at jsonnn.main(jsonnn.java:14)
    Caused by: java.lang.ClassNotFoundException: org.glassfish.json.JsonProviderImpl
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at javax.json.spi.JsonProvider.provider(JsonProvider.java:94)
    ... 2 more
    
  • Bass
    Bass over 5 years
    It is also worth mentioning that version 1.0 (of both the API and the implementation) is the last one to be supported on Java 1.8. Versions 1.1 onwards require Java 1.9 (class file version 53.0).
  • Mike
    Mike over 5 years
    That's not correct - JSON-P 1.1 was released in Java EE 8, which supports Java SE 8.
  • ExactaBox
    ExactaBox over 4 years
    It appears that as of the end of 2018, the maven/gradle package names changed to jakarta.json:jakarta.json-api and org.glassfish:jakarta.json. eclipse-ee4j.github.io/jsonp