GlassFish OSE 3.1 is out with WebSocket support included

By now you likely know that we released 3.1 of GlassFish today.  It's all over twitter with much of the jubilation around the return of clustering and HA support.  But closer to my own heart is the inclusion, finally, of websockets support.  I've blogged about it before, so I won't go in to too many details here.  But this is the first actual release of GlassFish to feature support for it which I'm personally pretty excited about. Some caveats still apply, however.  WebSockets are an exciting new technology but still remain under active development.  The version of the specification shipped with GlassFish 3.1 is the -76 version which is rather old by now.  It is still, as of this writing at least, the version supported by most of the browsers that support websockets.  So the good news is that apps you write today should work with most of the browsers out there.  As the specification evolves, however, browsers will begin to support newer versions of the specification and the GlassFish code will no longer work.

In the grizzly source tree, I have implemented support for the -05 version of the specification (with work started on the -06 version) for the 1.9 tree (which ships with GlassFish).  Should you find yourself needing newer support, I have written a simple bash script that will do that heavy lifting for you.  The script below needs to be run from the glassfish3/glassfish/modules directory.  In addition, you'll need to specify the version of grizzly you'd like to upgrade to.  The -05/-06 support will be present in 1.9.33 release coming up soon.

#! /bin/sh

if [ -z "${NEWVER}" ]
	echo Please specify the new version as a parameter

asadmin stop-domain
for i in grizzly-*
	[ $? -eq 0 ] && mv -v ${DEP}-${NEWVER}.jar $i

rm -r ../domains/domain1/osgi-cache/felix/

asadmin start-domain

This script will download the artifacts we've pushed to maven and update your existing grizzly jars.  It will also stop and restart your glassfish server for you so you don't need to worry about that.  The -05 spec is not compatible with the -76 version shipped with GlassFish 3.1 and we do not support the -76 version in the newer code for a variety of security/sanity related reasons.  So know that once you upgrade, you'll need browser support for the new version or your apps will stop working.

A word of warning, though.  I've done this locally and it works just fine.  But, as with any patch, you should back up your GlassFish directory first and/or test it in a development environment first.  If you have a support contract with Oracle, you'll likely need to discuss with them first to see how it would impact any agreements you have.  Ominous as that may sound, this should be safe enough to do (especially for a development environment) but just consider yourself warned.

WebSocket support is evolving constantly along the protocol itself.  While API changes are kept to a minimum, as we upgrade our support for the newer specifications and you upgrade your system to support them, you might encounter various changes in the API.  I really try to minimize such changes but please understand that things can change from release to release as everything beings to stabilize over the next few months.

I'm working on a number demos to help you get started with your own applications.  I'll be sharing a handful of those and presenting on building websocket applications at next month's The ServerSide Java Symposium in Las Vegas.  I'll be covering development using both 1.9 (and GlassFish 3.1) as well as grizzly 2.0 which just went final as well.  If you're there, please stop by and say hi.  I'd be happy to try to answer any questions you might have.

Why GCJ is bad (for newbies) and why Sun is to blame

I spend a fair bit of time helping out beginning Java programmers. My favorite is when they ask why their swing code doesn't work. When they post their stacktrace, there's all the GCJ/GIJ classes. I explain to them how GCJ isn't java and doesn't (fully) support swing and that they should just download Sun's VM and work with that. The problem with this scenario is multifaceted. For many, they use Debian (or some derivative) and the Debian ideologues choose ideology over functionality and ship a partial, non-certified implementation of a VM call it "java." Beginners, unaware of the distinction, run into problems and blame Java rather than misguided package managers. Others get it closer to right, like gentoo, and make it relatively easy to install Sun's VM. However, it's not entirely the package managers' fault. Sun's insistence on the pointless click-through license to download the VM make it impossible for most linux distros to sanely package a working java implementation. (The same also holds true for maven/ivy repositories but that's another matter.) Since no one can redistribute the VM and many/most of the Sun provided libraries, automated package management becomes impossible and people, like RedHat/Fedora, end up shipping GCJ and calling it Java even though it is demonstrably not Java.

Now, I know some of you will point at Fedora Core shipping Eclipse all pre-compiled with GCJ but I'd like to point out that most of the hard stuff (the UI) is already native code. I have nothing against GCJ, per se, but calling it Java and making it the default Java package is misleading and, I think, just plain wrong.

Sun's insistence on this licensing is leading to efforts like what our friends over at the Apache Software Foundation are working on: complete, reimplementation of all (major) java specifications with "sane" licensing terms that are freely redistributable. So rather than working with the community to speed the progress of these APIs, they've "forced" the community to reimplement things under terms we're comfortable with. With yesterday's announcement that McNeally stepped down as Sun's CEO and Schwartz taking the helm, I'm hopeful we'll see some progress on this front.

I know the issue has been beaten to death, but maybe now we'll see a truly open source(tm) VM. I think the model of OpenOffice, Apache's httpd, and Linux make a great model. Sun can keep the trademark and even "editorial" control over the main source tree. But greater freedom in using the VM can only lead to greater involvment from the community. Examples, like python, PHP, perl, and ruby show that languages can have open communities contributing without fragmentation. There are far too many bugs that have languished for far too long in the bug parade. Opening up the source to more traditional open source models can only help in the long run. I know many people who are turned away by the relatively draconian licensing terms the source is currently under.

Anyway, to return to my original point, Sun's licensing is creating some awkward situations around the use and deployment of Java applications that serve no real practical purpose that I can see.  I think it's time to open it up a bit.