Search code examples
javaspringspring-websocket

Remove dependency on Jackson


In Spring-MVC you have the ability to remove the Jackson library as a dependency and replace it with your own using this method:

protected void configureMessageConverters(List<HttpMessageConverter<?>> converters)

I am trying to do the same thing for Spring-Websocket so I have overridden both of these methods:

@Bean public CompositeMessageConverter brokerMessageConverter()
protected boolean configureMessageConverters(List<MessageConverter> messageConverters)

However there is still a dependency on Jackson somewhere and I can't figure out where.

EDIT

Here is a stack trace:

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException
    at org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService.getDefaultTransportHandlers(DefaultSockJsService.java:81)
    at org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService.<init>(DefaultSockJsService.java:74)
    at org.springframework.web.socket.config.annotation.SockJsServiceRegistration.createSockJsService(SockJsServiceRegistration.java:231)
    at org.springframework.web.socket.config.annotation.SockJsServiceRegistration.getSockJsService(SockJsServiceRegistration.java:198)
    at org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration$StompSockJsServiceRegistration.getSockJsService(WebMvcStompWebSocketEndpointRegistration.java:113)
    at org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration.getMappings(WebMvcStompWebSocketEndpointRegistration.java:87)
    at org.springframework.web.socket.config.annotation.WebMvcStompEndpointRegistry.getHandlerMapping(WebMvcStompEndpointRegistry.java:122)
    at org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurationSupport.stompWebSocketHandlerMapping(WebSocketMessageBrokerConfigurationSupport.java:60)
    at com.test.wsb.config.WebsocketConfig$$EnhancerBySpringCGLIB$$b414d315.CGLIB$stompWebSocketHandlerMapping$4(<generated>)
    at com.test.wsb.config.WebsocketConfig$$EnhancerBySpringCGLIB$$b414d315$$FastClassBySpringCGLIB$$f17bc7ca.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
    at com.test.wsb.config.WebsocketConfig$$EnhancerBySpringCGLIB$$b414d315.stompWebSocketHandlerMapping(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)

Solution

  • SPR-11963 has been created following this question, and is now resolved.

    This has landed in Spring Framework 4.0.6.