Error 415 when sending request to Sse subscribe method
03:50 14 Oct 2025

I have an application using Java 11, Spring, Apache CXF 3.4.2, Tomcat and Server Sent Events. How do I fix the 415 Unsupported Media Type error that occurs when sending the specified request to the specified endpoint?

curl --request GET \
  --url 'http://localhost:8080/api/shipMovementSubscribe?=' \
  --header 'Content-Type: text/event-stream' \
  --header 'User-Agent: insomnia/11.6.1' \
  --header 'gameLink: someText'

Response:

< HTTP/1.1 415 Unsupported Media Type
< Server: Apache-Coyote/1.1
< Date: Mon, 13 Oct 2025 12:56:00 GMT
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: origin, content-type, accept, authorization
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
< Access-Control-Max-Age: 1209600
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Content-Length: 0
public class RestService implements GameApi {

    public static Logger LOG = LoggerFactory.getLogger(RestService.class);
    private static final Map playersConnectionsMap = new HashMap<>();

    @Resource
    private MasterRepository masterRepository;
    @Resource
    private GameRepository gameRepository;
    @Resource
    ObjectMapper objectMapper;
    @Context
    private Sse sse;

    @GET
    @Path("/shipMovementSubscribe")
    @Produces(MediaType.SERVER_SENT_EVENTS)
    public void shipMovementSubscribe(@Context SseEventSink sseEventSink
            , @Context Sse sse, MoveChipDTO moveChipDTO
            , @Context HttpHeaders headers) {


        UUID gameId = GAME_ID;

        if (!playersConnectionsMap.containsKey(gameId)) {
            playersConnectionsMap.put(gameId, sse.newBroadcaster());
        }
        playersConnectionsMap.get(gameId).register(sseEventSink);
    }
}

I tried to add header 'Accept: text/event-stream' to request.

java tomcat cxf server-sent-events