Miles to go …

October 23, 2008

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

Filed under: javaserverfaces, netbeans, totd — arungupta @ 7:00 am

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:

  • EDR2 Specification
  • Javadocs
  • Release Notes
  • JavaScript API
  • JSP TLD
  • Facelets2 TLD

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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

October 21, 2008

NetBeans is turning 10 next week!

Filed under: general, netbeans — arungupta @ 11:30 pm


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.

Happy Birthday NetBeans!

And miles to go …

Technorati: netbeans birthday glassfish

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

October 20, 2008

Relevance of Open Source during Financial Crisis – GlassFish, MySQL, OpenSolaris, VirtualBox, NetBeans, …

Filed under: general, netbeans — arungupta @ 5:00 am

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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

October 17, 2008

SOAP and REST – both equally important to Sun

Filed under: webservices — arungupta @ 3:29 pm

“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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

TOTD #49: Converting a JSF 1.2 application to JSF 2.0 – @ManagedBean

Filed under: javaserverfaces, netbeans, totd — arungupta @ 9:46 am

This is a follow up to TOTD #48 which showed how to convert a JSF 1.2 application to use new features of JSF 2.0. In this blog, we’ll talk about a new annotation added to the JSF 2.0 specification – @ManagedBean.

@ManagedBean is a new annotation in the JSF 2.0 specification. The javadocs (bundled with the nightly) clearly defines the purpose of this annotation:

The presence of this annotation on a class automatically registers the class with the runtime as a managed bean class. Classes must be scanned for the presence of this annotation at application startup, before any requests have been serviced.

Essentially this is an alternative to <managed-bean> fragment in “faces-config.xml”. This annotation injects a class in the runtime as a managed bean and then can be used accordingly.

Using this annotation, the following “faces-config.xml” fragment from our application:

<managed-bean>
        <managed-bean-name>cities</managed-bean-name>
        <managed-bean-class>server.Cities</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>dbUtil</managed-bean-name>
        <managed-bean-class>server.DatabaseUtil</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>cities</property-name>
            <value>#{cities}</value>
        </managed-property>
    </managed-bean>

is simplified to

@Entity
@Table(name = “cities”)
@ManagedBean(name=”cities”, scope=”request”)
@NamedQueries({@NamedQuery(…)})
public class Cities implements Serializable {

and

@ManagedBean(name=”dbUtil”, scope=”request”)
public class DatabaseUtil {

    @ManagedProperty(value=”#{cities}”)
    private Cities cities;

The specification defines that managed bean declaration in “faces-config.xml” overrides the annotation.

A worthy addition to this annotation is “eager” attribute. Specifying this attribute on the annotation as @ManagedProperty(…, eager=”true”) allows the class to be instantiated when the application is started. In JSF 1.2 land, developers write their own ServletContextListeners to perform this kind of task. And this can of course be specified in “faces-config.xml” as <managed-bean eager=”true”>.

Section 11.5.1 of JSF 2.0 EDR2 specification defines several similar annotations that can be used to simplify “faces-config.xml”.

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 EDR1″ 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 glassfish mojarra netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

October 15, 2008

TOTD #48: Converting a JSF 1.2 application to JSF 2.0 – Facelets and Ajax

Filed under: javaserverfaces, netbeans, totd — arungupta @ 5:00 am

TOTD #47 showed how to deploy a JSF 1.2 application (using Facelets and Ajax/JSF Extensions) on Mojarra 2.0-enabled GlassFish.  In this blog we’ll use new features added in JSF 2.0 to simplify our application:

  • Use integrated Facelets and resource re-location to simplify our facelets
  • Replace JSF Extensions Ajax API with new in-built JavaScript APIs to expose Ajax functionality.

Let’s get started!

  • Re-create the app as defined in TOTD #47. This app is built using JSF 1.2 core components and Facelets. It uses JSF Extensions for adding Ajax capabilities. Lets change this app to use newer features of JSF 2.0.
  • Edit “faces-config.xml” and change the value of faces-config/@version from “1.2″ to “2.0″.
  • Remove the following fragment from “faces-config.xml”:
        <application>
            <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
        </application>

    This fragment is no longer required because Facelets is the default view technology in JSF 2.0. But it’s important to remember that JSF 2.0 Facelets is disabled by default if “WEB-INF/faces-config.xml” is versioned at 1.2 or older.

  • Remove the following code fragment from “web.xml”:
            <init-param>
              <param-name>javax.faces.LIFECYCLE_ID</param-name>
              <param-value>com.sun.faces.lifecycle.PARTIAL</param-value>
            </init-param>

    This is only required if JSF Extensions APIs are used.

  • Edit “welcome.xhtml” and replace code with:
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    <html xmlns=”http://www.w3.org/1999/xhtml”
          xmlns:ui=”http://java.sun.com/jsf/facelets”
          xmlns:h=”http://java.sun.com/jsf/html”>
        <ui:composition>
            <h:head>
                <h1><h:outputText value=”What city do you like ?” /></h1>
            </h:head>
           
            <h:body>
                <h:form prependId=”false”>
                    <h:panelGrid columns=”2″>
                        <h:outputText value=”CityName:”/>
                        <h:inputText value=”#{cities.cityName}”
                                     title=”CityName”
                                     id=”cityName”
                                     required=”true”
                                     onkeyup=”javax.faces.Ajax.ajaxRequest(this, event, { execute: ‘cityName’, render: ‘city_choices’});“/>
                        <h:outputText value=”CountryName:”/>
                        <h:inputText value=”#{cities.countryName}” title=”CountryName” id=”countryName” required=”true”/>
                    </h:panelGrid>
                   
                    <h:commandButton action=”#{dbUtil.saveCity}” value=”submit”/>
                    <br/><br/>
                    <h:outputText id=”city_choices” value=”#{dbUtil.cityChoices}”></h:outputText>
                   
                    <br/><br/>
                    <h:message for=”cityName” showSummary=”true” showDetail=”false” style=”color: red”/><br/>
                    <h:message for=”countryName” showSummary=”true” showDetail=”false” style=”color: red”/>
                </h:form>
            </h:body>
            <h:outputScript name=”ajax.js” library=”javax.faces” target=”header”/>
        </ui:composition>
       
    </html>

    The differences are highlighted in bold and explained below:

    • “template.xhtml” is no longer required because standard tags are used to identify “head” and “body”.
    • <h:head> and <h:body> are new tags defined in JSF 2.0. These tags define where the nested resources need to be rendered.
    • <h:outputScript> is a new tag defined in JSF 2.0 and allows an external JavaScript file to be referenced. In this case, it is referencing “ajax.js” script and is rendered in “head”. The script file itself is bundled in “jsf-api.jar” in “META-INF/resources/javax.faces” directory. It adds Ajax functionality to the application.</<br /> li>
    • “javax.faces.Ajax.ajaxRequest” function is defined in the JavaScript file “ajax.js”. This particular function invocation ensures that “city_choices” is rendered when execute portion of the request lifecycle is executed for “cityName” field. The complete documentation is available in “ajax.js”. Read more details about what happens in the background here.

    Notice how the Facelet is so simplified.

  • Refactor “result.xhtml” such that the code looks like as shown below:

    The changes are explained in the previous step, basically a clean Facelet using standard <h:head> and <h:body> tags and everything else remains as is.

And that’s it, just hit “Undeploy and Deploy” in NetBeans IDE and your application should now get deployed on Mojarra 2.0-enabled GlassFish. To reiterate, the main things highlighted in this blog are:

  • Facelets are integrated in Mojarra 2.0.
  • New tags for resource re-location allow a simpler and cleaner facelet embedded in a JSF application.
  • JavaScript APIs provide a clean way to expose Ajax functionality in JSF app.

And all of these features are defined in the JSF 2.0 specification. So if you are using Mojarra then be assured that you are developing a standards compliant user interface.

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 EDR1″ 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 glassfish mojarra netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

October 14, 2008

TOTD #47: Getting Started with Mojarra 2.0 nightly on GlassFish v2

Filed under: javaserverfaces, netbeans, totd — arungupta @ 5:53 am

Java Server Faces 2.0 specification (JSR 314, EDR2) and implementation (soon to be EDR2) are brewing. This blog shows how to get started with Mojarra – Sun’s implementation of JSF.

GlassFish v2 comes bundled with Mojarra 1.2_04 which allows you to deploy a JSF 1.2 application. This blog explains how you can update GlassFish v2 to use Mojarra 2.0 nightly. And then it deploys a simple JSF 1.2-based application on this updated GlassFish instance, there by showing that your existing JSF 1.2 apps will continue to work with Mojarra 2.0-enabled GlassFish. This is an important step because it ensures no regression, unless it was a compatibility fix :)

  1. Re-create a simple JSF 1.2 application as described in TOTD #42, TOTD #45 and TOTD #46. This application allows to create a list of cities and store them in a backend database. It uses JSF Extensions to show suggestions, using Ajax, based upon the cities already entered and also uses Facelets as the view technology. Alternatively you can use any pre-existing JSF 1.2 application.
  2. Download Mojarra 2.0 latest nightly.
  3. Follow Release Notes to install the binary, the steps are summarized here for convenience (GlassFish installed in GF_HOME):
    1. Backup “GF_HOME/lib/jsf-impl.jar”.
    2. Copy the new “jsf-api” and “jsf-impl” JARs from the unzipped Mojarra distribution to “GF_HOME/lib”.
    3. Edit “GF_HOME/domains/<domain-name>/config/domain.xml” and add (or update the existing “classpath-prefix”) ‘classpath-prefix=”${com.sun.aas.installRoot}/lib/jsf-api.jar” in the java-config element.
    4. Restart your server.
  4. Deploy the application on Mojarra 2.0-enabled GlassFish, that’s it!

The application is accessible at “http://localhost:8080/Cities/faces/welcome.xhtml”. Some of the screen captures are shown below.

If only “S” is entered in the city name, then the following output is shown:

Now with “San” …

And another one with “De” …

With JSF 2.0, Ajax capabilities and Facelets are now part of the specification and have already been integrated in Mojarra. A follow up blog entry will show how to use that functionality.

The downloaded Mojarra bundle has some samples (in “samples” folder) to get you started, have a look at them as well!

File JSF related bugs here using “2.0.0 EDR1″ version and ask your questions on .

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

Technorati: totd javaserverfaces glassfish mojarra netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

October 10, 2008

LOTD #10: Running GlassFish on Joyent Accelerator

Filed under: general, lotd — arungupta @ 10:52 am
Joyent provides a cloud computing environment for all your needs.  

Beyond their typical reasons (scale on demand, pay for what you use, PHP/Rails/Python/Java pre-installed and ready to go, billions of page views and others), now there is another reason to use their cloud.

The instructions to configure GlassFish on Joyent cloud are really clean and simple. Check them out here!

Do you know that Rails applications can be deployed (without any packaging) on GlassFish v3 ? Check out more details here.

All previous entries in this series are archived at LOTD.

Technorati: lotd joyent glassfish

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

September 27, 2008

LOTD #9: Advantages of JRuby over MRI

Filed under: lotd, web2.0 — arungupta @ 2:17 pm

Andreas blogged about why he likes JRuby even though he dislikes Java.

JRuby is “It’s just Ruby” with more than 50,000 tests to ensure MRI compliance. The blog highlights that there is no need to know Java, at all, to run JRuby. Here are some advantages that are described in the blog:

  1. JVM runtime optimization
  2. Efficient memory usage
  3. Native threads to spread work on multiple cores
  4. Great garbage collection to make memory usage more efficient
  5. JIT and AOT compilation
  6. Inegration with Java libraries
  7. Running Rails applications on existing Java application servers
  8. Documentation and specs

Read more details here.

Do you know Rails applications can be deployed (without any packaging) on GlassFish v3 ? Check out more details here.

Technorati: lotd jruby ruby rubyonrails glassfish

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

September 23, 2008

LOTD #9: Slides for Deploying and Monitoring Ruby on Rails Tutorial @ Rails Conf Europe 2008

Filed under: lotd, web2.0 — arungupta @ 5:00 am

During Rails Conf Europe 2008 Day 1 I attended an excellent tutorial on Deploying and Monitoring Ruby on Rails. The session very clearly explained the several deployment options with Rails. My notes from the session are here and the slides are now available. 

Here are couple of snapshots from the slide:

The complete set of slides from Rails Conf Europe 2008 are available here.

Technorati: conf railsconf glassfish deployment rubyonrails berlin

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
« Newer PostsOlder Posts »

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress