Home » Java » Enterprise Java » Jersey SSE capability in Glass Fish 4.0.1

About Abhishek Gupta

Jersey SSE capability in Glass Fish 4.0.1

logo-glassfishGlass Fish bundles different Reference Implementations for various Java EE specifications e.g. Weld for CDI, Mojarra for JSF, Tyrus for WebSocket, Jersey for JAX-RS. Glass Fish 4.0.1 is in the pipeline and slated to cover updates for many of the components/modules which both include new features and bug fixes of course.

Server Sent Events feature in Jersey will be supported with Glass Fish 4.0.1. Let’s try and test out this feature:

  1. Download the latest Glass Fish build from here

  3. Unzip the contents of the ZIP installer and configure the same in your IDE (I am using NetBeans).
    Note: I am using using JDK 8. Remember to configure Glass Fish to use the same.






  5. Make sure you include the highlighted JARS (below) in your class path. These are available under GF_INSTALL/glassfish/modules.



Now, the sample code for Jersey SSE feature demonstration. Its relatively simple.

There are three primary classes involved:


It serves as a Producer of stream of events and is modeled as JAX-RS resource which emits events when invoked with a GET method. The returned event streams are abstracted in the form of org.glassfish.jersey.media.sse.EventOutput on to which a org.glassfish.jersey.media.sse.OutboundEvent object is written. The OutboundEvent consists of the actual event data.



This class serves as consumer of the events produced by the AResource.java class. This is a simple JAX-RS client which sends a GET request to the published JAX-RS resource, reads the org.glassfish.jersey.client.ChunkedInput and further extracts the actual event data from org.glassfish.jersey.media.sse.InboundEvent instance.



As commonly the case with JAX-RS, this serves as bootstrap class.


To test the SSE functionality from server ( producer ) to client ( consumer ), deploy your application and just access the Servlet on http://you_gfish_ip:port/JerseySSE/SSETest. You should see the following logs:



About the FishCAT – Glass Fish Community Acceptance Testing program. Everyone is welcome to participate!

More on Jersey and Server Sent Events here.

This was a rather quick one…Not bad ! Now you have time to go and do something more useful!


Reference: Jersey SSE capability in Glass Fish 4.0.1 from our JCG partner Abhishek Gupta at the Object Oriented.. blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....



Leave a Reply

Your email address will not be published. Required fields are marked *


Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.