I\'m developing a Java webapp with Spring as the main framework (Spring core, Spring mvc, Spring security, Spring data, Spring websocket are notably used).
Declaring
I found a dirty solution. I don't like it, but given the lack of answers on SO (see also : Dispatcher-servlet cannot map to websocket requests ), as well as from current and former colleagues, I had to go forward with the project and implemented a dirty fix.
The dirty fix is to Autowire
the SimpMessagingTemplate
in Controller and Scheduled classes (all scanned by the dispatcher-servlet
, where the websocket tag
is declared), and to pass the SimpMessagingTemplate
as a parameter to service methods (declared in the root context
).
This solution is not transparent (the SimpMessagingTemplate
should be autowired directly in services ideally) but it definitely fixes the problem.