JEE7 release is just around the corner. Due to JRE security reason, my understanding is the release was postponed until next year. Short summary about Java EE 7 (JSR-342) can be found here and overview can be found here with very cool slide. My interest in WebSocket technology was high since last year. I’ve struggled to create my first WebSocket demo last year – there were many earlier implementation postings, but I had hard time finding newer GlassFish implementation. I learned that WebSocket 1.0 as a part of JEE7 supports method annotations around WebSocket lifecycle methods along with straight method implementations. If you want to know the detail, check this out.
In this posting, I’d like to explain how to set up GlassFish (latest build 4.0-b87) within Eclipse and explain some of troubles that I had. I didn’t want to install OEPE bundle. OEPE gives the whole package and makes it easier to configure, but I had some frustrating experience previously and decide not to go with OEPE.
First of all, I had to get rid of previously install GlassFish Plug in and GlassFish Tool in the Eclipse Juno. Click Help > About Eclipse > Install Details and remove any GlassFish related installation. I skipped this step and couldn’t deploy web application from the Eclipse. Symptom was the deployment hangs at 69% and no response from the server in Eclipse. There is a blog about how to clear old version of GlassFish tools in the Eclipse. For details, look at this blog.
Installation & Configuration
Once you are done,
- Time to download and install GlassFish 4.0. Scroll to the bottom and download the latest GlassFish.
- Install GlassFish.
- Start up Eclipse and make sure you have the latest JDK. At least 7.
- Now, it is time to install GlassFish Tool. It seems there are two ways of doing it. In my case, first approach (Preeference > Install/Update > Add Available Software Site) didn’t work well. Site URL is http://download.java.net/glassfish/eclipse/juno.
- Second approach is Help > New Software Install > past above URL.
- As soon as you do that, GlassFish Tool and Document will show up and you can install those in the Eclipse.
Coding & Testing
Now, time to code and test. I captured the code from Markus Eisele’s blog. The servlet is demonstrating by print out JSON object from JsonObjectBuilder.
Testing is simple, just start the GlassFish 4.0 and test localhost:8080/JEE7Test/JsonTester
Since I configured GlassFish 4.0 with JEE7, I’d like to modify my WebSocket chat demo using annotations and deploy to GlassFish 4.0. This will be a fun exercise and I will have a chance to read more JEE7 API documents.