0


I am using JDK 1.8.0_231 and Apache-Tomcat-8.0.36.
I am trying to upgrade Tomcat to version 9.0.
After defining the app to use the new Tomcat version, I am getting a NullPointer exception exception when the app calls flushBatch():

java.lang.NullPointerException
    at org.apache.tomcat.websocket.PerMessageDeflate.sendMessagePart(PerMessageDeflate.java:322)
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:284)
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:258)
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.flushBatch(WsRemoteEndpointImplBase.java:121)
    at org.apache.tomcat.websocket.WsRemoteEndpointBase.flushBatch(WsRemoteEndpointBase.java:48)

This is the code where the app fails:

private void sendMessage(String message, int attemptsNum) throws IOException {
        try {
            if (session.isOpen()) {
                RemoteEndpoint.Basic basicRemote = session.getBasicRemote();
                basicRemote.sendText(message);
                basicRemote.flushBatch();
            }
        } catch (IllegalStateException | NullPointerException | IOException e) {
            ... // handle exception code
        }
    }

This error doesn't happen in Tomcat version 8.0.36.
I also tried to use Tomcat 8.5.50, but got the same exception.

Has anyone encountered this issue?

sky_knight
  • 17
  • 3

0 Answers0