Server-sent event does not work with jersey SSE

后端 未结 4 2061
无人共我
无人共我 2021-01-06 04:05

I am trying to use JavaScript SSE from Jersey. I have Following code in my resource. I am hosting on Java7 and Tomcat 7. I dont get any error. But I don\'t see data either o

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-06 04:52

    I have to do the following to make it work with tomcat 7.0.69 and java 1.8, and jersey 2.22.2 Just sharing it if it comes to any use of any body.

    1. Add the following dependency in your Pom file :

        
          org.glassfish.jersey.containers
          jersey-container-servlet-core
          2.22.2
        
      
        
          org.glassfish.jersey.core
          jersey-client
          2.22.2
        
      
        
          org.glassfish.jersey.media
          jersey-media-json-processing
          2.22.2
        
      
            org.glassfish.jersey.containers
            
            jersey-container-servlet
            2.22.2
          
      
          
            org.glassfish.jersey.media
            jersey-media-sse
            2.22.2
          
      
    2. Needs to be servlet 3 so Heading of the web.xml should be like this : < ?xml version="1.0" encoding="UTF-8"? > < web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" >

    3. Jersey Servlet Container should be async-supported, so add it in the jersey servlet in the web.xml :

    < async-supported>true< /async-supported >

    1. If you use any filter make sure it also async-supported :

      < async-supported>true< /async-supported>

提交回复
热议问题