Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Status 500 - Provider org.glassfish.json.JsonProviderImpl not found

I am using netbeans-8, jdk 7,tomcat 8.05. I created a webapp in netbeans and added javax.json api to my project, the code shows no errors, but when i run my servlet the below error occurs.

HTTP Status 500 - Provider org.glassfish.json.JsonProviderImpl not found

type Exception report

message Provider org.glassfish.json.JsonProviderImpl not found

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.json.JsonException: Provider org.glassfish.json.JsonProviderImpl not found
    javax.json.spi.JsonProvider.provider(JsonProvider.java:97)
    javax.json.Json.createObjectBuilder(Json.java:266)
    NewServlet.doGet(NewServlet.java:24)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause

java.lang.ClassNotFoundException: org.glassfish.json.JsonProviderImpl
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1132)
    java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:190)
    javax.json.spi.JsonProvider.provider(JsonProvider.java:94)
    javax.json.Json.createObjectBuilder(Json.java:266)
    NewServlet.doGet(NewServlet.java:24)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.3 logs.

Apache Tomcat/8.0.3
like image 453
Ravi Chandra Durvasula Avatar asked Apr 02 '14 12:04

Ravi Chandra Durvasula


2 Answers

The javax.json api (provided in the JSON Processing API jar) is good only for compiling the application.

If you want to run the application, you have to download the JSON Processing RI jar, as explained here: https://jsonp.java.net/download.html

The JSON Processing RI jar contains the org.glassfish.json.JsonProviderImpl class you are missing.

like image 136
M. Luisa Carrión Avatar answered Sep 21 '22 20:09

M. Luisa Carrión


From this answer you could replace javax.json dependency by its org.glassfish implementation.

Maven repo, gives:

<dependency>
  <groupId>org.glassfish</groupId>
  <artifactId>javax.json</artifactId>
  <version>1.0.4</version>
</dependency>
like image 20
Juh_ Avatar answered Sep 21 '22 20:09

Juh_