title: SpringFramework registerWebSocketHandlers not working
body: <p>I am trying to register a AbstractWebSocketHandler implementation in a class that implements SpringFrameworks WebSocketConfigurer and extends SpringFrameworks AbstractWebSocketMessageBrokerConfigurer. In the websockethandler, I print out messages on the afterConnectionEstablished and afterConnectionClosed methods but I never see those messages in the appserver logs. I haven't been able to determine what I am doing incorrectly yet. Any advice you can give will be very much appreciated.</p>
  
  <p>AbstractWebSocketHandler class:</p>
  
  <pre><code>import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  import org.springframework.web.socket.CloseStatus;
  import org.springframework.web.socket.WebSocketSession;
  import org.springframework.web.socket.handler.AbstractWebSocketHandler;
  
  public class ImomWebSocketHandler extends AbstractWebSocketHandler {
  
      private static final Logger logger = LogManager.getLogger();
  
      @Override
      public void afterConnectionEstablished(WebSocketSession session) throws Exception {
          logger.info("Connection established");
          System.out.println("ImomWebSocketHandler Connection Established");
          // this is where the IMOM Analysis Engine connection will be established
      }
  
      @Override
      public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
          logger.info("Connection closed. Status: " + status);
          System.out.println("ImomWebSocketHandler Connection closed. Status: " + status);
          // this is where the IMOM Analysis Engine connection will be closed
      }
  }
  </code></pre>
  
  <p>WebSocketConfigurer class:</p>
  
  <pre><code>import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.messaging.simp.config.MessageBrokerRegistry;
  import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
  import org.springframework.web.socket.config.annotation.EnableWebSocket;
  import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
  import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
  import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
  import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
  import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
  
  import gov.inl.ecsi.websocket.handler.ImomWebSocketHandler;
  
  @Configuration
  @EnableWebSocketMessageBroker
  @EnableWebSocket
  public class ImomWebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer implements WebSocketConfigurer 
  {       
      // This exposes a STOMP WebSocket/SockJS endpoint at the URL path /imom where 
      // messages whose destination starts with "/command/ae" are routed to 
      // message-handling methods (i.e. application work) with MessageMapping /command/ae annotation
      // The messages whose destinations start with "/topic" or "/queue" will be routed to the 
      // message broker (i.e. broadcasting to other connected clients)
      // It is very common, however, for destinations to be path-like strings 
      // where "/topic/.." implies publish-subscribe (one-to-many) and 
      // "/queue/" implies point-to-point (one-to-one) message exchanges.
      @Override
      public void configureMessageBroker(final MessageBrokerRegistry registry) {
          registry.enableSimpleBroker(new String[] { "/topic", "/queue" });
          registry.setApplicationDestinationPrefixes(new String[] { "/imom" });
      }
  
      // this is the websocket STOMP endpoint, it goes with the MessageMapping
      @Override
      public void registerStompEndpoints(StompEndpointRegistry arg0) {
          // Client connects to var socket = new SockJS('/GCCSWebSocketApp/command');
          arg0.addEndpoint(new String[] { "/command" }).withSockJS();
      }
  
      //
      // http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-server-runtime-configuration
      // Each underlying WebSocket engine exposes configuration properties that
      // control runtime characteristics such as the size of message buffer sizes,
      // idle timeout, and others.
      //
      // For Tomcat, WildFly, and GlassFish add a
      // ServletServerContainerFactoryBean to your WebSocket Java config
      @Bean
      public ServletServerContainerFactoryBean createWebSocketContainer() {
          ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
          container.setMaxTextMessageBufferSize(32768);
          container.setMaxBinaryMessageBufferSize(32768);
          return container;
      }
  
      @Override
      public void registerWebSocketHandlers(WebSocketHandlerRegistry arg0) {
          arg0.addHandler(imomWebSocketHandler(), "/imom").withSockJS();
      }
  
      @Bean
      public ImomWebSocketHandler imomWebSocketHandler() {
          return new ImomWebSocketHandler();
      }
  }
  </code></pre>
  
  <p>log4j2.xml</p>
  
  <pre><code>&lt;Configuration status="warn" monitorInterval="30"&gt;
      &lt;Appenders&gt;
          &lt;Console name="Console" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout pattern="[%t] %d{HH:mm:ss} %c{1} [%p] - %m%n"/&gt;
          &lt;/Console&gt;
          &lt;!-- &lt;RollingFile name="LogFile" fileName="C:/Temp/ImomLogfile.log"
                  filePattern="C:/Temp/ImomLogfile-%d{yyyy-MM-dd}-%i.log.zip"&gt;
              &lt;PatternLayout pattern="[%t] %d{yyyy-MM-dd HH:mm:ss.SSS} %c [%p] - %m%n"/&gt;
              &lt;Policies&gt;
                  &lt;TimeBasedTriggeringPolicy /&gt;
                  &lt;SizeBasedTriggeringPolicy size="10 MB"/&gt;
              &lt;/Policies&gt;
              &lt;DefaultRolloverStrategy max="5"/&gt;
          &lt;/RollingFile&gt; --&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
          &lt;Root level="trace"&gt;
              &lt;AppenderRef ref="Console"/&gt;
          &lt;/Root&gt;
          &lt;Logger name="gov.inel" level="info" additivity="false"&gt;
              &lt;AppenderRef ref="Console" level="info"/&gt;
              &lt;!-- &lt;AppenderRef ref="LogFile" level="info"/&gt; --&gt;
          &lt;/Logger&gt;
          &lt;Logger name="gov.inl" level="info" additivity="false"&gt;
              &lt;AppenderRef ref="Console" level="info"/&gt;
              &lt;!-- &lt;AppenderRef ref="LogFile" level="info"/&gt; --&gt;
          &lt;/Logger&gt;
          &lt;Logger name="imom" level="info" additivity="false"&gt;
              &lt;AppenderRef ref="Console" level="info"/&gt;
              &lt;!-- &lt;AppenderRef ref="LogFile" level="info"/&gt; --&gt;
          &lt;/Logger&gt;
          &lt;Logger name="org" level="info" additivity="false"&gt;
              &lt;AppenderRef ref="Console" level="error"/&gt;
              &lt;!-- &lt;AppenderRef ref="LogFile" level="error"/&gt; --&gt;
          &lt;/Logger&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>