glassfish
  1. glassfish
  2. GLASSFISH-20909

Error (NPE) with WebSockets (GF4 in NB7.4) using Decoder for JSON object - removing decoder allows onMessage to Work

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 4.0_b89_RC5
    • Fix Version/s: None
    • Component/s: web_socket
    • Labels:
      None
    • Environment:

      Windows 7, NB 7.4, GF 4.0b89.

      Description

      Ran into issue in normal project, so I created a "toy project" to isolate issue...but seeing the same results.

      Created simple WebSockets app with @ServerEndpoint annotated class, Person (lastName, firstName), PersonEncoder, & PersonDecoder. App works fine without encoder/decoder designated in endpoint, but adding encoders= and decoders= to the @ServerEndpoint annotation causes an error on receipt of message:

      SEVERE: java.lang.NullPointerException
      at org.glassfish.tyrus.core.EndpointWrapper.findApplicableDecoders(EndpointWrapper.java:313)
      at org.glassfish.tyrus.core.EndpointWrapper.onMessage(EndpointWrapper.java:495)
      at org.glassfish.tyrus.server.TyrusEndpoint.onMessage(TyrusEndpoint.java:174)
      at org.glassfish.tyrus.websockets.DefaultWebSocket.onMessage(DefaultWebSocket.java:156)
      at org.glassfish.tyrus.websockets.frametypes.TextFrameType.respond(TextFrameType.java:66)
      at org.glassfish.tyrus.websockets.DataFrame.respond(DataFrame.java:102)
      at org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler.onDataAvailable(TyrusHttpUpgradeHandler.java:113)
      at org.apache.catalina.connector.InputBuffer$ReadHandlerImpl.processDataAvailable(InputBuffer.java:488)
      at org.apache.catalina.connector.InputBuffer$ReadHandlerImpl.onDataAvailable(InputBuffer.java:453)
      at org.glassfish.grizzly.http.io.InputBuffer.append(InputBuffer.java:855)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:222)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      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:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:744)

      I'm hoping this is something simple I'm overlooking, but if so, I'm consistently overlooking it.

      Happy to upload the simple test project I created if it will help. To duplicate, I just let NB create a new webapp, added a Websocket Endpoint, & the Person and enc/decoder classes, filling in annotations & interfaces as simply as I could for testing. Please do email me for files and/or clarification, happy to fill in any details I may have inadvertently left out.

        Activity

        Hide
        Pavel Bucek added a comment -

        just noticed - your decoder class (PersonDecoder) is not public? That definitely won't work..

        Show
        Pavel Bucek added a comment - just noticed - your decoder class (PersonDecoder) is not public? That definitely won't work..
        Hide
        Pavel Bucek added a comment -

        I compared line numbers against Tyrus 1.0 tag and seems like my last comment is true. Your decoder is not public, so the instance cannot be created. Last version of Tyrus also prints out the exception which caused this (was fixed as part of different issue some time ago).

        closing as invalid.

        Show
        Pavel Bucek added a comment - I compared line numbers against Tyrus 1.0 tag and seems like my last comment is true. Your decoder is not public, so the instance cannot be created. Last version of Tyrus also prints out the exception which caused this (was fixed as part of different issue some time ago). closing as invalid.
        Hide
        HecklerMark added a comment -

        What the...???

        I'm not sure when that happened, but - sorry about that.

        Still seeing some oddness, but will isolate it and see where it leads. Thanks, Pavel.

        Mark

        Show
        HecklerMark added a comment - What the...??? I'm not sure when that happened, but - sorry about that. Still seeing some oddness, but will isolate it and see where it leads. Thanks, Pavel. Mark
        Hide
        Pavel Bucek added a comment -

        no need to apologise The error message was far from being usable so it is/was a bug in some form.

        Feel free to file another issue when you are done with your evaluation. You can use Tyrus issue tracker directly - it will be more visible for me that way. https://java.net/jira/browse/TYRUS

        Show
        Pavel Bucek added a comment - no need to apologise The error message was far from being usable so it is/was a bug in some form. Feel free to file another issue when you are done with your evaluation. You can use Tyrus issue tracker directly - it will be more visible for me that way. https://java.net/jira/browse/TYRUS
        Hide
        HecklerMark added a comment -

        Thanks, Pavel (sheepish grin)...

        I was also the "lucky recipient" of some malformed JSON coming in. Once we cleaned that up, everything seems to be operating as expected!

        Thanks again for your help,
        Mark

        Show
        HecklerMark added a comment - Thanks, Pavel (sheepish grin)... I was also the "lucky recipient" of some malformed JSON coming in. Once we cleaned that up, everything seems to be operating as expected! Thanks again for your help, Mark

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            HecklerMark
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: