Tuesday, January 12, 2010

How things gets screwed up, when you're not thinking...

Short note how JNLP is screwed up in the GlassFish.
You like GlassFish, aren't ya? Now, consider, you want distribute your application over JNLP, as I did on my radio website. It is an MP3 player with an ability send SMS messages, so far. Note, the website is in Ukrainian language, but you can simply click on that whacky image somewhere in the middle of the article. :-)

Since it is Java Web Start, the way you put it to the GlassFish is using Enterprise Application, then create a client to it, and then put your stuff there, pack as an ".ear" and deploy. Sounds cool, right? Yes, sounds very-very cool. Note that since it is Java Web Start, you don't want to listen to your complaining users for like "WTF is this?!" etc., instead you want your application:
  • Be damn fast.
  • Be damn small.
  • Be damn quick.
However, not with Enterprise Application. Once you've packed your app as ".ear", it will suck up a sh*tload of useless jar's, verify each by unpacking, checking etc. On an average user's Vista laptop, where all the resources went to antivirus and antimalware package, you do not want it happen ever. Some of my users complained they had to wait 8 (eight, EIGHT) minutes to load a very little tiny application, like that one. Take a look what you've got in your cache among other crap: Java EE jar! Application Server runtime! OMG!..

Now... The obvious question is how to cure all this mess to make your 200K application start literally in a moment? Forget stupid Enterprise Application, once you go with JNLP. It is still good if you do EJB things (I do, so far so good). Never touch JEE for client part (make sure it is server thing in your app) and deploy as a simple GUI that talks to your server via webservices (REST or SOAP is fine). Deploy it just manually, as a static data somewhere on the server.

How deploy it manually on GlassFish. I assume you're using NetBeans? If no, you should. :-) So go to the properties of your Project, select "Web Start enabled", sign your jars with an SSL certificate and rebuild all the stuff. In your Project's "dist" folder you will find ready to go app (almost). Then edit codebase URL in order it point to your website over HTTP instead using file:// from local system. Tar/gzip all the dist/ folder with everything inside, scp to your server and unpack to the static folder of the GlassFish ($ROOT/domains/$DOMAIN/docroot) or, if it is GlassFish + Liferay, then look inside deployed Liferay package.

That's it.

P.S. Sun, I hope Oracle will kick your ass very hard to gently encourage you think properly and organize your technology the way it be once actually usable for everyone.


Tomas Varaneckas said...

Three years ago at one Java conference the audience was asked to raise hands if they used IDEA, Eclipse or NetBeans. Among hundreds of developers only three people were using NetBeans. The speaker joked - "security, please escort NetBeans users outside".

Even though NetBeans is much better now than it was at the time of that conference, it's still a slow, Sun technology oriented bloatware.

Same goes with GlassFish, EJB and other Java Enterprise technologies. Why would you ever use anything with word enterprise in it for developing homegrown software?

BM said...

Nah, "homegrown software" does not mean "primitive software". It means "made in a spare time", exactly like entire Linux OS. :-)

I would not agree for the statement that GlassFish or NetBeans are bloated as same as EJB is bloated. Take a look at BEA. Or enjoy the utter mess of POJO-based hodgepodge, called JBoss. As of Eclipse, it works hell bad on Mac OS X and Solaris, while and IDEA is a payware, although code editor is sweet. Both of them, IDEA and Eclipse has lack of number of great features that NetBeans offers (debugger, profiler, Visual VM, Swing GUI Editor, JavaFX GUI editor, consistent package manager where packages are not killing each other by version mishmash etc). So after quite a research and experience for a years (Spring, Eclipse, Tomcat etc) I see that Sun stack is the best and getting constantly better, while alternative stuff is inconsistent, different from each other, not well integrated and has a number of drawbacks.

FYI, Oracle stated they're gonna invest in exactly GlassFish and NetBeans, because they see a great value here.

But still the whole point of my complain is targeting Sun's major f*ckups, where entirely good things are screwed by a little piece of stuff, that makes all the feature unusable.