[GLASSFISH-20481] GlassFish does not log exceptions thrown by WebSocket callback methods Created: 07/May/13  Updated: 19/Sep/14  Resolved: 24/Jul/13

Status: Resolved
Project: glassfish
Component/s: web_socket
Affects Version/s: 4.0_b87_RC3
Fix Version/s: 4.1

Type: Bug Priority: Major
Reporter: Nigel Deakin Assignee: stepan.kopriva
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
is related to MQ-297 RuntimeExceptions are not being logged Resolved
is related to GLASSFISH-20467 RuntimeException not logged on setMes... Resolved


If a webSocket @OnMessage callback throws a RuntimeException this is ignored by the container and nothing is logged in the server log to indicate that anything went wrong. This can lead to important failures being completely missed.

Here's an example of a webSocket @OnMessage callback that throws a {{RuntimeException}:

    public void onMessage(final String message, final Session client) {
        Logger.getLogger(SampleWebSocket.class.getName()).log(Level.INFO, "SampleWebSocket.onMessage called");
        throw new RuntimeException("Ooh la la");

I think this is a bug in GlassFish. If a RuntimeException exception is thrown by a EJB business method then GlassFish logs it (with a stack trace) in the server log. However if a RuntimeException exception is thrown in a WebSocket callback then nothing is logged.

Comment by jitu [ 07/May/13 ]

I agree with Nigel. I also observed the same behaviour (though Tyrus passes the exception to @OnError method correctly). If Tyrus is logging with lower level, then it should log with WARNING level.

Comment by stepan.kopriva [ 19/Jul/13 ]

I have tried the provided sample with both glassfish-4.0-b89 (http://dlc.sun.com.edgesuite.net/glassfish/4.0/nightly/glassfish-4.0-b89-05_15_2013.zip) and latest glassfish from trunk. In both cases the result is the same - the exception gets logged with level SEVERE. So the level is not correct, however the exception gets logged.

I agree with Jitu that the level should be WARNING. If you agree and won't provide any other proposal, I will change the log level to WARNING next week.

Comment by Nigel Deakin [ 22/Jul/13 ]

I repeated my test case using the above @OnMessage callback with the released GlassFish Server Open Source Edition 4.0 (build 89) and am still not seeing any exception or error message logged in the server log when the @OnMessage callback throws an exception. I am using the default logging settings.

Comment by stepan.kopriva [ 24/Jul/13 ]

Fixed. If an Exception is thrown in the Endpoint which does not have @OnError method, the Exception is logged on INFO level.

Generated at Sat Aug 29 19:46:55 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.