2

I am trying to use Spring websockets with Genson instead of Jackson. When I try and connect from a client I get the following:

java.lang.IllegalStateException: A SockJsMessageCodec is required but not available: Add Jackson 2 to the classpath, or configure a custom SockJsMessageCodec.

It would appear I need to set a custom message codec.

I can see that a .setMessageCodec method appears on the TransportHandlingSockJsService but I can't see anywhere in the configuration options where I can actually set it.

I think the the .setMessageCodec method should be present on the SockJsServiceRegistration class so it can be set from configuration...but it isn't...any ideas?

EDIT: I believe this is a bug so have raised: https://jira.spring.io/browse/SPR-12091

Cheetah
  • 13,785
  • 31
  • 106
  • 190

1 Answers1

0

Have a look at this issue https://jira.spring.io/browse/SPR-11184.

It looks like that you could implement it by overriding the configureMessageConverters method in WebSocketMessageBrokerConfigurer.

eugen
  • 5,856
  • 2
  • 29
  • 26
  • 1
    I've already done that to convert the messages using Genson, but this question is actually about configuring a converter (they call it codec) for sockjs messages. – Cheetah Aug 17 '14 at 16:55