2 Replies Latest reply on Jul 2, 2018 10:04 AM by Vlastimil Dolejš

    ClassCastException inside JsrWebSocketFilter.java  / Wildfly 13 only /

    Grzegorz U Newbie

      Hi

       

      My code works properly inside wildfly starting from 8 up to 12 version.

       

      It stop in wildfly 13 with following exception.

       

      Exception handling request to /notifications: javax.servlet.ServletException: java.lang.ClassCastException: org.apache.shiro.web.servlet.ShiroHttpSession cannot be cast to io.undertow.servlet.spec.HttpSessionImpl

      Caused by: java.lang.ClassCastException: org.apache.shiro.web.servlet.ShiroHttpSession cannot be cast to io.undertow.servlet.spec.HttpSessionImpl
              at io.undertow.websockets.jsr.JsrWebSocketFilter.doFilter(JsrWebSocketFilter.java:131)
              at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
              at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
              at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
              at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
              at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
              ... 52 more


      github show modification named 'UNDERTOW-1301 Web Socket sessions are not closed when session is invalidated' committed on Mar 8.

       

      Looking at undertow code i've found two critical modification associated with file websockets-jsr/src/main/java/io/undertow/websockets/jsr/JsrWebSocketFilter.java

       

      1. at line 131
      final HttpSessionImpl session = (HttpSessionImpl) req.getSession(false);

       

      2. at line 183

      HttpSessionImpl session = (HttpSessionImpl) se.getSession();


      My war is linked with shiro library so my http sessions are using ShiroHttpSession object.

       

      ShiroHttpSession class and HttpSessionImpl implements HttpSession.


      Question to developer ...  what about following changes in undertow code to use HttpSession interface.

       

      1. final HttpSession session = req.getSession(false);

      2. HttpSession session = se.getSession();

       

      Regards
      Grzegorz