jersey
  1. jersey
  2. JERSEY-2323

If OAuth Access Token response is in JSON format and if it contains array then it is not able to parse it with JSON parser(like jackson).

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.1
    • Fix Version/s: 2.7
    • Component/s: None
    • Labels:
      None

      Description

      If OAuth Access Token response is in JSON format and if it contains array then it is not able to parse it with JSON parser(like jackson). Below is the stack trace:

      javax.ws.rs.ProcessingException: Error reading entity from input stream.
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:868)
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:785)
      at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:267)
      at org.glassfish.jersey.client.InboundJaxrsResponse$1.call(InboundJaxrsResponse.java:111)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:397)
      at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:108)
      at org.glassfish.jersey.client.oauth2.AuthCodeGrantImpl.finish(AuthCodeGrantImpl.java:341)
      at com.adeptia.api.rest.adapter.internal.AdapterService.storeAccessToken(AdapterService.java:141)
      at com.adeptia.api.rest.adapter.internal.AdapterService.handleOperation(AdapterService.java:253)
      at com.adeptia.api.rest.adapter.internal.AdapterService.getResponse(AdapterService.java:219)
      at com.adeptia.api.rest.resources.oauth.AdapterProcessor.processRequest(AdapterProcessor.java:42)
      at com.adeptia.api.rest.resources.oauth.AdapterProcessor.callService(AdapterProcessor.java:28)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
      at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:402)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:349)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:106)
      at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:259)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010)
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:499)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
      at org.eclipse.jetty.server.Server.handle(Server.java:349)
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
      at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
      at java.lang.Thread.run(Unknown Source)
      Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
      at [Source: org.glassfish.jersey.message.internal.EntityInputStream@7fb43f0f; line: 1, column: 69]
      at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
      at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)
      at org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:44)
      at org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:13)
      at org.codehaus.jackson.map.deser.std.MapDeserializer._readAndBind(MapDeserializer.java:319)
      at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:249)
      at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:33)
      at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
      at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
      at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:239)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:211)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:139)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1109)
      at org.glassfish.jersey.client.oauth2.AuthCodeGrantImpl$DefaultTokenMessageBodyReader.readFrom(AuthCodeGrantImpl.java:406)
      at org.glassfish.jersey.client.oauth2.AuthCodeGrantImpl$DefaultTokenMessageBodyReader.readFrom(AuthCodeGrantImpl.java:382)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:239)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:211)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:139)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1109)
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:853)
      ... 64 more
      Jan 11, 2014 11:16:44 AM org.glassfish.jersey.filter.LoggingFilter log
      INFO: 6 * Server responded with a response on thread qtp1143571160-25
      6 < 200
      6 < Content-Type: application/json

        Activity

        Hide
        amityvipin added a comment -

        I have fixed this issue with below changes:
        https://gist.github.com/amityvipin/8368241

        Show
        amityvipin added a comment - I have fixed this issue with below changes: https://gist.github.com/amityvipin/8368241
        Hide
        Michal Gajdos added a comment -

        Fix available.

        Show
        Michal Gajdos added a comment - Fix available.

          People

          • Assignee:
            Michal Gajdos
            Reporter:
            amityvipin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1 hour
              1h
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 minute Time Not Required
              1m