I tried to run this example from the spring site: tutorial except the Spring Boot part.
Web.xml
Archetype C
Also if you want not to pass login/password to server (as you might rely on Spring security) then you shouldn't use
stompClient.connect('', '', function(frame) {
but instead
stompClient.connect({}, function(frame) {
Take a look here: https://github.com/spring-guides/gs-messaging-stomp-websocket/issues/10
The mistake was wrong controller mapping. I have:
@MessageMapping("/hello")
@SendTo("/topic/greetings")
public Greeting greeting(HelloMessage message) throws Exception
and in the jsp:
stompClient.subscribe("<c:url value='/topic/greetings'/>", function(greeting){...
and
stompClient.send("<c:url value='/app/hello'/>", {}, JSON.stringify({ 'name': name }));
The right ones are:
stompClient.subscribe('/topic/greetings', function(greeting){...
stompClient.send('/app/hello', {}, JSON.stringify({ 'name': name }));
The c:url adds the root of the project, when I removed it the app worked. However c:url(the root) is rquired when create new socket with SockJs here:
var socket = new SockJS("<c:url value='/hello'/>");