jsonp
  1. jsonp
  2. JSONP-2

java.lang.NoSuchMethodError: javax.json.stream.JsonGenerator.writeStartObject() [GF b69]

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      mac Os . JDK7

      Description

      I've tried to play with some exemple given at http://java.net/projects/jsonp/sources/git/show/demos/jaxrs?rev=6897259e97eef8caeeea7ca4d9cc030177b465f4

      But It seems like the latest version of JSONP is not integrated yet into glassfish 4 b69. This is the exception I'm facing :

      [#|2013-01-02T02:47:08.886-0500|WARNING|glassfish4.0|javax.enterprise.web|_ThreadID=84;_ThreadName=http-listener-1(3);_TimeMillis=1357112828886;_LevelValue=900;|StandardWrapperValve[jsonServlet]: Servlet.service() for servlet jsonServlet threw exception
      java.lang.NoSuchMethodError: javax.json.stream.JsonGenerator.writeStartObject()Ljavax/json/stream/JsonGenerator;
      at mjug.adopjsr.jaxrs2.tasks.jsonServlet.writeWikiExample(jsonServlet.java:35)
      at mjug.adopjsr.jaxrs2.tasks.jsonServlet.doGet(jsonServlet.java:30)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:342)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:732)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:671)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:176)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:172)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:175)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:781)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:578)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:558)
      at java.lang.Thread.run(Thread.java:722)

      #]

      I've attached the servlet i've used to test the exemple.

        Activity

        Hide
        b_faissal added a comment -

        package mjug.adopjsr.jaxrs2.tasks;

        import javax.json.Json;
        import javax.json.JsonArrayBuilder;
        import javax.json.JsonObject;
        import javax.json.JsonObjectBuilder;
        import javax.json.stream.JsonGenerator;
        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import java.io.IOException;
        import java.io.OutputStream;

        /**

        • Created with IntelliJ IDEA.
        • User: faissalboutaounte
        • Date: 13-01-01
        • Time: 15:35
        • To change this template use File | Settings | File Templates.
          */
          @WebServlet(name = "jsonServlet", urlPatterns = "/json")
          public class JsonServlet extends HttpServlet {
          protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        }

        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

        { writeWikiExample(response.getOutputStream()); }

        private void writeWikiExample(OutputStream os) {
        try (JsonGenerator gene = Json.createGenerator(os))

        { gene.writeStartObject() .write("firstName", "John") .write("lastName", "Smith") .write("age", 25) .writeStartObject("address") .write("streetAddress", "21 2nd Street") .write("city", "New York") .write("state", "NY") .write("postalCode", "10021") .writeEnd() .writeStartArray("phoneNumber") .writeStartObject() .write("type", "home") .write("number", "212 555-1234") .writeEnd() .writeStartObject() .write("type", "fax") .write("number", "646 555-4567") .writeEnd() .writeEnd() .writeEnd(); }

        }
        }

        Show
        b_faissal added a comment - package mjug.adopjsr.jaxrs2.tasks; import javax.json.Json; import javax.json.JsonArrayBuilder; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.json.stream.JsonGenerator; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; /** Created with IntelliJ IDEA. User: faissalboutaounte Date: 13-01-01 Time: 15:35 To change this template use File | Settings | File Templates. */ @WebServlet(name = "jsonServlet", urlPatterns = "/json") public class JsonServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { writeWikiExample(response.getOutputStream()); } private void writeWikiExample(OutputStream os) { try (JsonGenerator gene = Json.createGenerator(os)) { gene.writeStartObject() .write("firstName", "John") .write("lastName", "Smith") .write("age", 25) .writeStartObject("address") .write("streetAddress", "21 2nd Street") .write("city", "New York") .write("state", "NY") .write("postalCode", "10021") .writeEnd() .writeStartArray("phoneNumber") .writeStartObject() .write("type", "home") .write("number", "212 555-1234") .writeEnd() .writeStartObject() .write("type", "fax") .write("number", "646 555-4567") .writeEnd() .writeEnd() .writeEnd(); } } }
        Hide
        b_faissal added a comment -

        I've also runned into this one :

        [#|2013-01-02T03:06:56.065-0500|WARNING|glassfish4.0|javax.enterprise.web|_ThreadID=82;_ThreadName=http-listener-1(1);_TimeMillis=1357114016065;_LevelValue=900;|StandardWrapperValve[jsonServlet]: Servlet.service() for servlet jsonServlet threw exception
        java.lang.InstantiationError: javax.json.JsonObjectBuilder
        at mjug.adopjsr.jaxrs2.tasks.jsonServlet.doGet(jsonServlet.java:30)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:342)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:732)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:671)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:176)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:172)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:175)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:781)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:578)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:558)
        at java.lang.Thread.run(Thread.java:722)

        #]

        the code is :

        JsonObject value = new JsonObjectBuilder()
        .add("firstName", "John")
        .add("lastName", "Smith")
        .add("age", 25)
        .add("address", new JsonObjectBuilder()
        .add("streetAddress", "21 2nd Street")
        .add("city", "New York")
        .add("state", "NY")
        .add("postalCode", "10021"))
        .add("phoneNumber", new JsonArrayBuilder()
        .add(new JsonObjectBuilder()
        .add("type", "home")
        .add("number", "212 555-1234"))
        .add(new JsonObjectBuilder()
        .add("type", "fax")
        .add("number", "646 555-4567")))
        .build();
        response.getWriter().write(value.toString());
        response.getWriter().close();

        Show
        b_faissal added a comment - I've also runned into this one : [#|2013-01-02T03:06:56.065-0500|WARNING|glassfish4.0|javax.enterprise.web|_ThreadID=82;_ThreadName=http-listener-1(1);_TimeMillis=1357114016065;_LevelValue=900;|StandardWrapperValve [jsonServlet] : Servlet.service() for servlet jsonServlet threw exception java.lang.InstantiationError: javax.json.JsonObjectBuilder at mjug.adopjsr.jaxrs2.tasks.jsonServlet.doGet(jsonServlet.java:30) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:342) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:732) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:671) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:176) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:172) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:175) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:781) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:578) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:558) at java.lang.Thread.run(Thread.java:722) #] the code is : JsonObject value = new JsonObjectBuilder() .add("firstName", "John") .add("lastName", "Smith") .add("age", 25) .add("address", new JsonObjectBuilder() .add("streetAddress", "21 2nd Street") .add("city", "New York") .add("state", "NY") .add("postalCode", "10021")) .add("phoneNumber", new JsonArrayBuilder() .add(new JsonObjectBuilder() .add("type", "home") .add("number", "212 555-1234")) .add(new JsonObjectBuilder() .add("type", "fax") .add("number", "646 555-4567"))) .build(); response.getWriter().write(value.toString()); response.getWriter().close();
        Hide
        jitu added a comment -

        Try with glassfish 4 promoted build : b70

        Show
        jitu added a comment - Try with glassfish 4 promoted build : b70
        Hide
        b_faissal added a comment - - edited

        Yes it works on b70

        But I'm not able to resolve the issue

        Show
        b_faissal added a comment - - edited Yes it works on b70 But I'm not able to resolve the issue

          People

          • Assignee:
            Unassigned
            Reporter:
            b_faissal
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: