Reputation: 847
I have a jetty server and i followed the instructions from https://examples.javacodegeeks.com/enterprise-java/jetty/jetty-websocket-example/
i defined a @ServerEndpoint
:
@ServerEndpoint("/jsr356toUpper")
public class ToUpper356Socket {
@OnOpen
public void onOpen(Session session) {
System.out.println("WebSocket opened: " + session.getId());
}
@OnMessage
public void onMessage(String txt, Session session) throws IOException {
System.out.println("Message received: " + txt);
session.getBasicRemote().sendText(txt.toUpperCase());
}
@OnClose
public void onClose(CloseReason reason, Session session) {
System.out.println("Closing a WebSocket due to " + reason.getReasonPhrase());
}
}
but i get :
Error during WebSocket handshake: Unexpected response code: 404 WrappedWebSocket @ VM222:161
when I am trying to reach to ws://localhost:8080/jsr356toUpper
Any suggestions ?
Upvotes: 1
Views: 856
Reputation: 847
Solved, apparently I used an old jetty plugin
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
instead of
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
Upvotes: 1