Monday Oct 27, 2008

GlassFish @ Silicon Valley Code Camp 2008

CodeCamp at FootHill College. Click Here for Details and Registration Sun Microsystems is a sponsor of Silicon Valley Code Camp, Nov 8-9, 2008.

More than 800 attendees have already registered and numbers are expected to bump up.

There are three sessions by the GlassFish team:

The code camp follows six principles:
  • by and for the developer community
  • always free
  • community developed material
  • no fluff – only code
  • community ownership
  • never occur during working hours
And then there is wireless, lunch on both days, excellent networking, and Saturday night barbecue - everything free. Check out the complete session schedule and more details here.

If you are local to bayarea, why would you not come ? :)

Register now!

A mashup on the main page shows speakers and attendees geographical distribution. This is created using JSON feeds for Attendees ZIP.  A snapshot is shown below:

A similar feed for sessions for is also available for and includes presentation date/time, associated tags and similar information. Would you like to create a fancy session viewer ? If chosen, it'll be highlighted at the conference.

Technorati: conf siliconvalleycodecamp glassfish

Sunday Oct 26, 2008

Silicon Valley Half Marathon 2008 Completed - best time so far

I completed Silicon Valley Half Marathon yesterday. Although I missed my target of 8 min/mile by 4 seconds but still improved my personal best by 3 min and 8 secs. Here are my official results:

A summary of half-marathoners:

And the top 5 finishers:

And then the complete results.

Even though the number of 1/2 marathoners were much smaller (957 instead of 6679) than my previous marathon but I still enjoyed the run. Going through familiar streets and neighborhood was the best part :)

Here is a short video at the start:

And another one at the finish line in Los Gatos High School:

No marathon can ever be completed without family support. All the practice takes a significant amount of time away from family. And it's certainly exciting when they accompany you, early in the morning, for the actual race. Many thanks to my family for helping in my marathons all through out these years :) Here are couple of pictures:

The massage at the end of the race by National Holistic Institute was certainly relaxing!

And of course a small photo album:

Here are my timings so far:

Marathon / Half Marathon Total Time Pace
Silicon Valley 1/2 2008 1:45:42 8:04
San Francisco 1/2 2008 1:52:44 8:25
San Francisco Full 2007 4:04:33 9:20
Silicon Valley Full 2006 4:06:57 9:25
San Francisco 1/2 2005 1:48:50 8:18

As you can see, they have improved over past years :) It only becomes interesting going forward because of the higher bar.

Any suggestions on good San Francisco Bay Area marathons ?

Technorati: running marathon svmarathon results

Thursday Oct 23, 2008

TOTD #51: Embedding Google Maps in Java Server Faces using GMaps4JSF

GMaps4JSF allows Google Maps to be easily integrated with any JSF application. This blog shows how to use this library with Mojarra - JSF implementation delivered from the GlassFish community.

TOTD #50 explains how to create a simple JSF 2.0 application and deploy on GlassFish v3 prelude using Mojarra 2.0 EDR2. The application allows to create a database of cities/country that you like. It uses integrated Facelets and the newly introduced JavaScript APIs to expose Ajax functionality. This blog shows how to extend that application to display a Google Map and Street View of the entered city using this library.
  1. Configure GMapsJSF library in the NetBeans project (created as described in TOTD #50)
    1. Download gmaps4jsf-core-1.1.jar.
    2. In the existing NetBeans project, right-click on the project, select Properties, Libraries, click on "Add JAR/Folder" and point to the recently download JAR.
    3. Configure Facelets support for this library. This is an important step since Facelets are the default viewing technology in JSF 2.0.
  2. In the NetBeans project, create a new Java class "server.CityCoordinates" that will use Google Geocoding APIs to retrieve latitude and longitude of the entered city. It also create a "details" entry by concatenating city and country name. Use the code listed below:

        private float latitude;
        private float longitude;
        private String details;
        private Cities cities;

        private final String BASE_GEOCODER_URL = "";
        private final String ENCODING = "UTF-8";
        private final String GOOGLE_MAPS_KEY = "GOOGLE_MAPS_API_KEY";
        private final String OUTPUT_FORMAT = "CSV";

        public String getLatLong() throws IOException {
            details = cities.getCityName() + ", " + cities.getCountryName();

            String GEOCODER_REQUEST =
                    BASE_GEOCODER_URL +
                    "q=" + URLEncoder.encode(details, ENCODING) +
                    "&key=" + GOOGLE_MAPS_KEY +
                    "&output=" + OUTPUT_FORMAT;
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(
                        new URL(GEOCODER_REQUEST).openStream()));
            String line = null;
            int statusCode = -1;
            while ((line = reader.readLine()) != null) {
                // 200,4,37.320052,-121.877636
                // status code,accuracy,latitude,longitude
                statusCode = Integer.parseInt(line.substring(0, 3));
                if (statusCode == 200) {
                    int secondComma = line.indexOf(",", 5);
                    int lastComma = line.lastIndexOf(",");
                    latitude = Float.valueOf(line.substring(secondComma+1, lastComma));
                    longitude = Float.valueOf(line.substring(lastComma+1));
                    System.out.println("Latitude: " + latitude);
                    System.out.println("Longitude: " + longitude);

            return "map";

        // getters and setters

    "getLatLong()" method retrieves geocoding information using HTTP by passing the city and country name, Google Maps API key and CSV output format. The result is then processed to retrieve status code, latitude and longitude. Add the following annotation to this class:

    @ManagedBean(name="coords", scope="request")

    This ensures that "server.CityCoordinates" is injected as a managed bean in the runtime.
  3. Add a new button in "welcome.xhtml" right after "submit" button as:

    <h:commandButton action="#{coords.getLatLong}" value="map"/>
  4. Add a new page "map.xhtml" as:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns=""
            <script src=";v=2&amp;key=ABQIAAAAF9QYjrVEsD9al2QCyg8e-hTwM0brOpm-All5BF6PoaKBxRWWERRHQdtsJnNsqELmKZCKghs54I-0Uw" type="text/javascript"> </script>
                <m:marker draggable="true">
                    <m:eventListener eventName="dragend" jsFunction="showStreet"/>
                <m:htmlInformationWindow htmlText="#{coords.details}"/>
                <m:mapControl name="GLargeMapControl" position="G_ANCHOR_BOTTOM_RIGHT"/>
                <m:mapControl name="GMapTypeControl"/>
            <br/> <br/>
            <m:streetViewPanorama width="500px" height="200px"
                                  latitude="#{coords.latitude}" longitude="#{coords.longitude}"
                                  jsVariable="pano1" />

            <script type="text/javascript">
                function showStreet(latlng) {

            <form jsfc="h:form">
                <input jsfc="h:commandButton" action="back" value="Back"/>

    The code is borrowed and explained in An Introduction to GMaps4JSF. Basically the code displays a Google Map and Street View where the latitude and longitude are bound by "server.CityCoordinates" managed bean. And these attributes are populated using the geocoding information earlier. The Street View corresponds to marker in the Map which is draggable. So if the marker is dropped to a different location in the map then the Street View changes accordingly.
  5. Add new navigation rules to "faces-config.xml" as:

That's it, now your application is ready!

Now when a city and country name are entered on "welcome.xhtml" and "map" button is clicked then the corresponding Google Map along with the street view are shown in next page.

If "San Jose" is entered on "http://localhost:8080/Cities/faces/welcome.xhtml" then the following page is shown:

Clicking on "map" button shows the following page:

If the marker is drag/dropped to 280 and 87 junction, then the page looks like:

Some other useful pointers:
Have you tried your JSF 1.2 app on Mojarra 2.0 ? Drop a comment on this blog if you have.

File JSF related bugs here using "2.0.0 EDR2" version and ask your questions on

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. An archive of all the tips is available here.

Technorati: totd javaserverfaces mojarra glassfish v3 netbeans gmaps4jsf googlemaps

TOTD #50: Mojarra 2.0 EDR2 is now available - Try them with GlassFish v3 and NetBeans 6.5

Yaaay, 50th tip!! The previous 49 tips are available here.

Mojarra EDR2 is now available - download binary and/or source bundle!

GlassFish v2 UR2 ships with Mojarra 1.2.0_04 and v3 prelude comes with 1.2.0_10. The Mojarra binaries in both v2 and v3 can be easily replaced by the new ones as described in Release Notes. Additionally, TOTD# 47 explains how to get started with Mojarra 2.0 on GlassFish v2. This blog will guide you through the steps of installing these bits on GlassFish v3 Prelude and show how to use them with NetBeans IDE.
  1. Download latest GlassFish v3 prelude and unzip.
  2. Start Updatetool from "bin" directory. The first run of the tool downloads and installs the tool. Start the tool by typing the command again to see the screen shown below:

  3. Click on "Update", "Accept" the license and the component is then installed in GlassFish directory. Optionally, you can click on "Installed Components" and then verify that bits are installed correctly.
  4. An EDR2 compliant application can now be directly deployed in these GlassFish v3 bits. There is some work required in order to use code completion, auto-fixing of Imports  and similar features in NetBeans 6.5 RC. The steps below describe that.
    1. In "Tools", "Libraries", click on "New Library ...", enter the name "JSF2.0" as shown:

    2. Click on "OK", "Add JAR/Folder..." and pick "glassfishv3-prelude/glassfish/modules/jsf-api.jar", click on "OK".
    3. Right-click on the NetBeans project, select "Properties", "Libraries" and remove "JSTL1.1" and "JSF1.2" libraries.
    4. Click on "Add Library ...", select the newly created "JSF2.0" library, click "Add Library" and then "OK".
  5. In order to run "Cities" application on these GlassFish bits copy MySQL Connector/J jar in "glassfishv3-prelude/glassfish/lib" directory and then deploy the application.

Here are some pointers to get started:

Have you tried your JSF 1.2 app on Mojarra 2.0 ? Drop a comment on this blog if you have.

File JSF related bugs here using "2.0.0 EDR2" version and ask your questions on

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. An archive of all the tips is available here.

Technorati: totd javaserverfaces mojarra glassfish v3 netbeans

Wednesday Oct 22, 2008

Tempo, Interval, Aerobic, Easy, Long runs etc ...

Still confused by the difference between tempo and interval running ?

How easy is an easy run ?

How long a long run should be ?

Here is a great article defining different types of runs/pace, advantages and how to do them properly.

Technorati: running tempo interval

Tuesday Oct 21, 2008 - An exhaustive marathon directory provides an exhaustive directory of marathons across continents.

The marathons can be selected by countries, month or by a keyword. The search feature is especially nice because it shows all the details about the race - marathon route, registration page, nearest marathons, community rating, and even hotel booking amongst many other features.

Did you know 167 marathons will be run in Oct 2008 alone ? And you think marathons are run only in New York, London, Boston and Chicago :)

This is a great resource if you are traveling on business and would like to satisfy your running desires!

The map above shows Metro Silicon Valley Marathon coming up over the weekend and I'll be running the 1/2 marathon.

My goal is to finish comfortably in under 2 hours (a conservative target). This is in addition to:
Drop a note if you are running Silicon Valley! Sun Microsystems has a corporate discount and you can save some money during this financial crisis :)

Technorati: running marathon svmarathon directory

NetBeans is turning 10 next week!

NetBeans is turning 10 next week!

Wow, it's been 10 years and the IDE has certainly evolved tremendously over these years. My first usage of NetBeans goes back to version 3.6 (Mar 2004). The What's New list shows Code Folding, Native L&F for Windows and MacOS and Arrange Windows using drag-and-drop amongst many other features. And today, it leverages the mauturity of Java platform and incorporates comprehensive tooling for languages and frameworks other than Java such as PHP, Ruby-on-Rails, Groovy-on-Grails, C/C++, JavaScript, and many others.

Read complete history of how Xelfi evolved into NetBeans IDE as you know today!

Don't forget to enter NetBeans Decathlon to receive a limited edition NetBeans 10th Anniversary Shirt. GlassFish is one of the featured projects and some suggestions to particpate are:
  • Try the latest GlassFish v3 prelude build with v3 plugin
  • Share your experience with NetBeans and GlassFish integration on forum thread
  • Demo NetBeans/GlassFish to a friend and post a blog entry. Several demos are available here.
This blog has published 174 entries (including 25 screencasts) dedicated to NetBeans as shown by the tag cloud:

I wonder if that count towards getting the limited edition shirt ;-)

Anyway, participate in all the action on NetBeans Birthday. Enjoy birthday wishes from the NetBeans team who make it all happen seamlessly.

<script type="text/javascript" src=""></script> <script type="text/javascript"> </script>

Happy Birthday NetBeans!

And miles to go ...

Technorati: netbeans birthday glassfish

Comet @ Ajax World 2008 West

Jim and I presented on "Using Comet to create a Two-Player Web Game" at Ajax World 2008 West yesterday. The talk explained the basic concepts of Comet, showed how a Tic Tac Toe game can be easily created using code walkthrough and then talked about future directions. The slides are available here and the code can be downloaded here.

A similar sample that can be deployed on Rails and Grails is described here. It uses GlassFish's support for multiple dynamic languages and associated web frameworks.

One of the benefits of delivering first talk in the morning is the ability to attend different sessions during the day. Of the different sessions I particularly enjoyed listening Bill Scott on Crafting Rich Web Interfaces.The talk explained six principles of rich web interaction with set of design patterns and real world examples. The slides are available here. All other sessions were mostly product pitches with very little value for developers.

Here are some pictures from the show:

And a complete album is available at:

Technorati: conf ajaxworld comet glassfish

Sunday Oct 19, 2008

Relevance of Open Source during Financial Crisis - GlassFish, MySQL, OpenSolaris, VirtualBox, NetBeans, ...

CIO published an article highlighting 5 cheap (or free) software that can be afforded during financial crisis. Their recommendations are:
  • Open Office ($0) instead of Microsoft Office ($110 for basic version)
  • Mozilla Thunderbird ($0) instead of Microsoft Outlook (lots of security issues)
  • GnuCash ($0) instead of Quicken ($30 for starter edition)
  • Alfresco ($0) instead of Sharepoint ($5K for five licenses)
  • Linux instead of Windows (non-zero cost, always virus-prone ;)
All the recommendations are open source and can be downloaded and used without any hidden clauses. In all cases the open source version is at par and sometimes better than the commercial version. And of course there is always the agility factor. You enounter a bug, somebody in the community fixes it (on priority if you have support subscription), patch available in the nightly and you are back in business.

Here are some more recommendations ...
  • GlassFish instead of Oracle Weblogic or IBM Websphere
  • MySQL instead of Oracle Enterprise or IBM DB2
  • OpenSolaris instead of Windows
  • NetBeans instead of IntelliJ
  • VirtualBox instead of VM Ware or any other virtualization software
  • and many more here
All these options are completely open source with a full enterprise support available from Sun Microsystems.

Now some actual price comparisons using GlassFish and MySQL Unlimited ...

That's $3 million savings over a period of 3 years!!!

And if the number of sockets/cores go up, that's just additional money you are wasting during this financial crisis. With GlassFish Enterprise Unlimited starting at $25,000 - no counting cores, sockets, support incidents, servers or auditing - you can deploy unlimited GlassFish instances for the same price charged for one WebLogic Enterprise Edition. GlassFish for Business explains the value of buying subscription for your deployments.

Here is another comparison for Total Cost of Ownership for MySQL compared with other databases:

Can your apps scale more than Google, Facebook, Yahoo or Wikipedia ? All these sites are powered by MySQL. Do they need to be more reliable than telco vendors such as Vodafone ? Again powered by MySQL.

In an open source world, why have a "30-day" evaluation period ?

In the times of financial crisis, why spend extra money when there are other better options available with HUGE savings ?

Open Source software is indeed a great way to cut costs. And Sun Microsystems offer a wide varitey of open source offerings (GlassFish, MySQL, OpenSolaris, VirutalBox, Linux, NetBeans and many others) that can help you during this financial crisis!

Technorati: opensource glassfish mysql netbeans opensolaris sun

Friday Oct 17, 2008

SOAP and REST - both equally important to Sun

"Sun moving away from SOAP to embrace REST" is the misleading title of an article recently published in SD Times. The article provides a good introduction to JAX-RS and Jersey. But I really wonder what motivated the author of this article to use this title. This blog, hopefully, provides a better context.

Jersey is the Reference Implementation of Java API for RESTful Web Services (JAX-RS, JSR 311) and was released earlier this week. The headline indicates that Sun is leaving SOAP and will support REST. The debate between REST and SOAP is not new and there are religious camps on both sides (even within Sun). And that's completely understandable because each technology has its own merits and demerits. But just because a new JSR aimed to make RESTful Web services easy in the Java platform is released, it does not mean Sun Microsystems is leaving existing technology in trenches.

The addition of Jersey to Sun's software portfolio makes the Web services stack from GlassFish community a more compelling and comprehensive offering. This is in contrast  to "moving away" from SOAP as indicated by the title. As a matter of fact, Jersey will be included as part of Metro soon, the Web Services stack of GlassFish. And then you can use JAX-WS (or Metro) if you like to use SOAP or JAX-RS (or Jersey) if you prefer RESTful Web services. It's all about a offering choice to the community instead of showing a direction.

Here are some data points for JAX-WS:
  • The JAX-WS 2.0 specification was released on May 11, 2006. There have been couple of maintenance releases since then and another one brewing.
  • Parts of Metro, the implementation of JAX-WS, are currently baked into GlassFish, embeddable in JBoss WS Stack, and also part of Oracle Weblogic and IBM Websphere.
  • The implementation stack is mature and used in several key customer deployments. 
  • JAX-WS is already included in Java SE 6 and hence available to a much wider audience.
  • As opposed to "moving away", JAX-WS 2.2 (currently being worked upon) will be included in Java EE 6 platform, as will Jersey be.
So I believe both SOAP and REST are here to stay, at least in the near future. And Sun Microsystems is committed to support them!

You still think Sun is moving away from SOAP ?

It seems a personal preference is interpreted as Sun's disinvestment in SOAP. It's good to have increased readership but not at the cost of misleading headlines :)

Technorati: jax-ws rest webservices metro sdtimes glassfish

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« October 2008 »