Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty-9.3.11.v20160721 - sendBinary() - java.lang.IllegalArgumentException: message cannot be null #903

Closed
kbh4r4th opened this issue Sep 6, 2016 · 4 comments

Comments

@kbh4r4th
Copy link

kbh4r4th commented Sep 6, 2016

We plan to use JSR-356 for WebSocket along with Jetty for Production deployment but Server ends in error while using sendBinary().

Could you check it?

Error trace:

java.lang.IllegalArgumentException: message cannot be null
at org.eclipse.jetty.websocket.jsr356.AbstractJsrRemote.assertMessageNotNull(AbstractJsrRemote.java:69)
at org.eclipse.jetty.websocket.jsr356.JsrAsyncRemote.sendBinary(JsrAsyncRemote.java:61)
at com.apple.sample.websocket.endpoint.FileServer.onMessage(FileServer.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:71)
at org.eclipse.jetty.websocket.jsr356.annotations.OnMessageTextCallable.call(OnMessageTextCallable.java:63)
at org.eclipse.jetty.websocket.jsr356.annotations.JsrEvents.callText(JsrEvents.java:197)
at org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver.onTextMessage(JsrAnnotatedEventDriver.java:378)
at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:66)
at org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver.onTextFrame(JsrAnnotatedEventDriver.java:360)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:162)
at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:376)
at org.eclipse.jetty.websocket.common.extensions.AbstractExtension.nextIncomingFrame(AbstractExtension.java:176)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.nextIncomingFrame(PerMessageDeflateExtension.java:105)
at org.eclipse.jetty.websocket.common.extensions.compress.CompressExtension.forwardIncoming(CompressExtension.java:142)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.incomingFrame(PerMessageDeflateExtension.java:85)
at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:220)
at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:220)
at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:256)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:679)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:511)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)

@kbh4r4th kbh4r4th changed the title Jetty-9.3.11.v20160721 - sendBinary - java.lang.IllegalArgumentException: message cannot be null Jetty-9.3.11.v20160721 - sendBinary() - java.lang.IllegalArgumentException: message cannot be null Sep 6, 2016
@jmcc0nn3ll
Copy link
Contributor

Are you certain you are not trying to send an empty binary message?

@kbh4r4th
Copy link
Author

kbh4r4th commented Sep 6, 2016

Yes, I am pretty sure that I don't send an empty binary message. The same code works on ApacheTomcat 7/8 without any issues.

@joakime
Copy link
Contributor

joakime commented Sep 6, 2016

This is the correct behavior for the JSR356 API.

See the javadoc for .sendBinary():
http://docs.oracle.com/javaee/7/api/javax/websocket/RemoteEndpoint.Async.html#sendBinary-java.nio.ByteBuffer-

We received a data (ByteBuffer) that was null (not empty), and the IllegalArgumentException is telling you that.

Looking at the stacktrace:

  • A Whole Text message was received
  • The @OnMessage method com.apple.sample.websocket.endpoint.FileServer.onMessage was called
  • While in this method, a call to RemoteEndpoint.Async#sendBinary(ByteBuffer) was called with a value of null for the data parameter.

@kbh4r4th
Copy link
Author

kbh4r4th commented Sep 6, 2016

My bad! I did debugging to ensure again whether null is sent but yes it sends null & hence the exception.

A system property was missed to be added in Jetty, which is required by the application to find the file location whereas its properly added in ApacheTomcat.

Jetty works perfectly.

Thanks @jmcc0nn3ll & @joakime for the help!

Closing the issue.

@kbh4r4th kbh4r4th closed this as completed Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants