Miles to go …

January 31, 2008

TOTD #23: JavaFX Client invoking a Metro endpoint

Filed under: webservices — arungupta @ 6:00 am

This TOTD is inspired by Learning JavaFX Script – Part 3. The original article explains how to invoke a Web service from a JavaFX client using NetBeans 5.5.1 and GlassFish v1. Newer version of both NetBeans and GlassFish are available since the article was written. This TOTD (tip of the day) explains how to invoke a Metro endpoint deployed on GlassFish v2 from a JavaFX client – all using NetBeans 6.

  1. Following screencast #ws7, create a plain (without Security or Reliability enabled) Metro endpoint using NetBeans 6 and GlassFish v2.
  2. In NetBeans 6 IDE, install the JavaFX plugin as described here.
  3. Create Web service client library – Creating a Web service client in JavaFX Script Application is causing a NullPointerException (issue #126352). The workaround I used is to create a separate library with client-side artifacts and then include it as dependency in the JavaFX client project.
    1. Create a new project of type "Java Class Library" as shown below:

      and click on "Finish".

    2. Enter the project name as "MetroClientLibrary" as shown below:

      and click on "Finish".

    3. Right-click on the newly created project, select "New", "Web Service Client...".
    4. Click on "Browse..." button next to "Project" radio button and select the deployed Web service from Metro endpoint project. If the Web service is deployed on a different machine then you may specify the WSDL URL. Specify the package name "client" as shown below:

      and click on "Finish".

    5. Once the Web service client-side artifacts are generated (indicated by expandable Web Service References tree node), right-click on the project and select "Build". This generates a JAR file that will be utilized later. The location of this jar file is shown in the Output console. In our case, it is

      C:\workarea\samples\javafx\MetroClientLibrary\dist\MetroClientLibrary.jar.

  4. Create JavaFX project
    1. Create a new JavaFX project by right-clicking in the Project explorer, selecting "New Project" and entering the values as shown below:

    2. Click on "Next >" and enter the values as shown below:

      and click on "Finish".

    3. Right-click on the newly created project, "Properties", "Libraries", "Add JAR/Folder" and select the JAR file created in "MetroClientLibrary" project as shown below:

      and click on "OK".

      Notice, Java SE 6 U4 is used to compile and run this project. If you are using an earlier version of Java SE 6, then you need to override JAX-WS 2.1 and JAXB 2.1 jars using endorsed mechanism as explained here. The classes in these jars are already bundled in Java SE 6 U4.

    4. In metroclient.Main.fx file, replace "// place your code here" with the following code:

      import java.lang.*;
      import javafx.ui.*;

      import client.NewWebServiceService;
      import client.NewWebService;

      class InputModel {
          attribute name: String?;
      }
      var inputModel = InputModel { };
      var nameField = TextField { };
      nameField.action = operation() {
          inputModel.name = nameField.value;
      };

      class ButtonClickModel {
          attribute result: String;
      }
      var model = new ButtonClickModel();

      Frame {
          title: "JavaFX Client -> Metro endpoint"
          width: 350
          height: 200
          content: GridPanel {
              rows: 3
              vgap: 5
              cells:
              [SimpleLabel {
                  text: "Name : "
              },
              nameField,
              SimpleLabel {
                  text: "Result from endpoint : "
              },
              Label {
                  text: bind "{model.result}"
              },
              Button {
                  text: "Invoke Web Service!"
                  action: operation() {
                      do {
                          try {
                              var service: NewWebServiceService = new NewWebServiceService();
                              var port: NewWebService = service.getNewWebServicePort();
                              var name: String = "{nameField.value}";
                              var result: String = port.sayHello(name);
                              System.out.println("response: {result}");
                              model.result = result;
                          } catch (e:
      Exception) {
                              System.out.println("exception: {e}");
                          }
                      }
                  }
              }
              ]
          }
          visible: true
      };

  5. Invoke the JavaFX client project
    1. Right-click on the recently create project ("MetroClient") and select "Run Project". The following window is displayed:

    2. Enter "Duke" in the text box and click on "Invoke Web Service!" button to see the result as shown below:

After following these steps, you have created a JavaFX client that can invoke a Metro endpoint project deployed on GlassFish – all using NetBeans IDE.

Now Metro provides secure, reliable, transactional and .NET 3.0 interoperable Web service. Have you tried/used any of those features in Metro ?

Please leave suggestions on other TOTD that you’d like to see. A complete archive is available here.

Technorati: totdd javafx metro glassfish netbeans webservices

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

January 30, 2008

South Bay Ruby Meetup Trip Report

Filed under: web2.0 — arungupta @ 10:00 pm

As mentioned earlier, I presented on "Rails powered by GlassFish & jMaki" at South Bay Ruby Meetup yesterday. The slides are available here.

The demos showed in the talk are listed below:

  • screencast #web9 – Create standalone and shared WARs that can be deployed on GlassFish
  • GlassFish v3 gem – Create a simple Rails app and run it using GlassFish gem instead of WEBrick or Mongrel
  • screencast #web8 – Create visually appealing views for Rails applications using jMaki

There were approx 25 attendees with an extremely interactive session. I would love to capture all the Q&A but the audience kept me busy :)

You can read about JRuby-on-GlassFish and NetBeans/Ruby support. GlassFish success stories are described in blogs.sun.com/stories.

Let me know if you are interested in having this talk at your Ruby meetup.

Technorati: conf jruby rubyonrails glassfish netbeans meetup netbeans

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

January 29, 2008

JRuby-on-Rails deployed on GlassFish – Success Story

Filed under: web2.0 — arungupta @ 6:02 am

There are several reasons you may deploy JRuby-on-Rails application on GlassFish:

  • Java EE is a long tested deployment platform and GlassFish is Java EE 5 compliant.
  • GlassFish “green” deployment model – just create a WAR and dump it in autodeploy directory. Typical Rails deployment requires to spawn multiple Mongrels, front-ended by Apache and then manage them through Capistrano.
  • Java EE and Ruby-on-Rails applications can be easily integrated in one container. This allows to host JRuby-on-Rails applications in organization who have already made investment in Java EE.
  • GlassFish comes with out-of-the-box clustering and high-availability support. Rails applications can certainly benefit from them.
  • GlassFish offers database connection pooling allowing you to reuse your database connections.
  • Last, but not the least, JRuby-on-Rails can leverage the extensive set of Java libraries.

I’m working on an article that will explain each of these in detail. In the meanwhile here is a live success story.

mediacast.sun.com (provides a public place for Sun employees to store large media files) released their version 2.0 – completely rewritten using JRuby-on-Rails and deployed on GlassFish. Igor has good details is his blog. Here are some excerpts:

Development environment: NetBeans 6, Mercurial plugin, WEBrick, GlassFish v2 UR1, MySQL
Deployment environment: 2 Load-balanced T2000, Solaris 10, Sun Java System Application Server 9.1 U1, JDK 6, MySQL

He has explained the pain points and areas of improvements very clearly. We are aware of the performance problems and already working on them!

Let us know if you have had success with deploying JRuby-on-Rails on GlassFish. Read all GlassFish success stories.

UPDATE (Feb 8) : Mediacast deployment diagram is now available here.

Technorati: glassfish netbeans jruby rubyonrails mediacast stories

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

500 Blog Entries Old

Filed under: General — arungupta @ 12:02 am

This is 500th blog entry on this blog :)

Here is the tag cloud indicating the major topics covered so far:

And here is a geographic distribution of readers:

Technorati: bsc 2008

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

January 28, 2008

GlassFish at WebGuild Web 2.0 Conference & Expo 2008 – Jan 29

Filed under: web2.0 — arungupta @ 12:02 am

Sun Microsystems is a sponsor of WebGuild’s Web 2.0 Conference & Expo and you can meet me at Sun booth in the exhibitor hall. Register for a FREE exhibitor pass here.

Ask me about:

  • How GlassFish provides an easy-to-use and production-quality development and deployment environment for your "Web 2.0" applications ?
  • How NetBeans IDE provides a rich extensible platform to create such applications ?
  • What is jMaki and how it allows you to use best tools & libraries to create Rich Internet Applications ?
  • How GlassFish is a "green" alternative for deploying JRuby-on-Rails applications ?
  • How RESTful Web services can be easily generated using Jersey from a database table ?
  • Or anything else you want to know :)

I will be at the WebGuild's Web 2.0 Conference & Expo

Technorati: conf jmaki jruby netbeans glassfish rubyonrails jruby jersey

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

January 27, 2008

Frankfurt to San Jose – $54.54 for one minute call

Filed under: General — arungupta @ 8:02 am

I used my credit card to call home (San Jose, CA) from Frankfurt Airport during a trip last year. And the calling company charged $54.54 for an approximately one minute call. Here is what I see in my credit card statement detail:

Transaction Date 12/10/2007
Transaction Description  INTL CL* 800-5762118 CA
Called From GERMANY GE Number: 0114901113
Called To LOS GATOS CA Number: xxx-xxx-xxxx
Time of Call: 00:22 Duration: 00:05
Charge: $54.54
Merchant Address INTERNATIONAL CALLING
511 E SAN YSIDRO BLVD
SUITE 1770
SAN YSIDRO CA 92173
USA

Gosh, this turned out to be an EXPENSIVE call!

The duration is listed as 00:05, i.e. 5 seconds. I remember talking for approx a minute. IMHO having no information is better than having incorrect one.

Fortunately, the customer service number was correct and I got some points clarified:

  • This call is placed through satellite and that’s why they charged this rate. He could not explain why satellite is used when credit card is used to call.
  • The pulse rate is 5 minutes. So the telephone company always charge in multiple of 5 minutes.
  • Talk to a live operator, inquire about the rates and then place the call. In the United States, making an operator-assisted call charges you more money. So this was completely non-intuitive to me.
  • Because of some stated law, the international calling rate, pulse rate and similar information cannot be placed on the phone equipment. Again, no reference to what/where the law is.
  • Use a pre-paid card to make the international call. This is a lesson learned for me, hard way!

The customer service contact also refunded part of the charges, but even then it’s still a lot!

Technorati: frankfurt airport traveltips phone

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

January 26, 2008

“Rails powered by GlassFish & jMaki” @ South Bay Ruby Meetup – Jan 29, 7pm

Filed under: web2.0 — arungupta @ 8:02 am
I’ll be speaking on "Rails powered by GlassFish & jMaki" at South Bay Ruby Meetup on Jan 29 (Tuesday) @ 7pm. Read more details here.

You’ll learn:

  • How GlassFish provides an easy-to-use and production-quality development and deployment environment for your JRuby-on-Rails applications ?
  • How GlassFish is a "green" alternative for deploying JRuby-on-Rails applications ?
  • What is GlassFish v3 Gem ?
  • How jMaki allows you to create visually appealing views for Rails applications ?
  • How NetBeans provide first-class support for creating Rails applications ?

Thanks to Bala for providing an opportunity to talk about our efforts! Let’s keep an interactive dialog and learn from each other :)

Technorati: conf jruby rubyonrails glassfish netbeans meetup

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

January 25, 2008

TOTD #22: Java SE client for a Metro endpoint

Filed under: webservices — arungupta @ 12:02 am

Metro is the Web services stack in GlassFish. It is your one-stop shop from a simple Hello World to Secure, Reliable,  Transactional and .NET 3.0 interoperable endpoint. Metro Tooling is provided by NetBeans and other options are explained here.

Screencast #ws7 describes how a Metro endpoint can be easily created and deployed on GlassFish and invoked from a Web client using NetBeans IDE. This TOTD (as requested here and here) describes how a Secure and Reliable Metro endpoint can be invoked using a Java SE client.

Here is my environment:

  • Windows Vista
  • NetBeans 6
  • GlassFish v2 (downloaded from glassfish.java.net and configured in NetBeans).
  • Java SE 1.6.0 U4

Let’s get started.

  1. Following screencast #ws7 create a plain (without Reliability and Security enabled) Metro endpoint.
  2. Create the Java SE client project
    1. In NetBeans IDE, create a new project of the type Java/Java Application. Name the project as "SEClient" and take all other defaults.
    2. Right-click on the newly created project, select "New", "Web Service Client...".
    3. Click on the "Browse..." button next to "Project" radio button and select the deployed Web service endpoint.
    4. Enter the package name as "client" and click on "Finish".
  3. Invoke the plain Metro endpoint
    1. Right-click on the project, select "Properties", "Libraries", "Add JAR/Folder" and add "webservices-rt.jar" from the "lib" directory of GlassFish installation. Click on "OK".
    2. Expand the "Web Service References" node in the project and drag the leaf node in the "main" method of "Main.java" of the client project.
    3. Change the value of parameter "name" to "Duke".
    4. Right-click the project and select "Run". This will build the project, invoke the endpoint and show the results in Output window as "Hello Duke".
    5. If your GlassFish instance is configured to show SOAP messages then the following SOAP messages will be shown in the output window:

      ====[com.sun.xml.ws.assembler.server:request]====
      <?xml version="1.0" ?>
      <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Body>
          <ns2:sayHello xmlns:ns2="http://server/">
            <name>Duke</name>
          </ns2:sayHello>
        </S:Body>
      </S:Envelope>
      ============
      ====[com.sun.xml.ws.assembler.server:response]====
      <?xml version="1.0" ?>
      <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Body>
          <ns2:sayHelloResponse xmlns:ns2="http://server/">
            <return>Hello Duke</return>
          </ns2:sayHelloResponse>
        </S:Body>
      </S:Envelope>
      ============

  4. Invoke the Reliable Metro endpoint
    1. Following the instructions in screencast #ws7, enable Reliability on Metro endpoint and re-deploy.
    2. In the client project, select the first child node of "Web Service References", right-click and select "Refresh Client".
    3. In the "Confirm Client Refresh" window, select "Also replace local wsdl file with original WSDLs located at:" checkbox and click on "Yes".
    4. Right-click the client project and select "Run". This will build the project, invoke the endpoint and show the results in Output window as "Hello Duke".
    5. The SOAP messages during this run will now contain Reliable Messaging protocol messages and resemble as shown below:

      ====[com.sun.xml.ws.assembler.server:request]====
      <?xml version="1.0" ?>
      <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Header>
          <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/SEEndpoint/HelloServiceService</To>
          <Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</Action>
          <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
          </ReplyTo>
          ...

  5. Invoke the Secure Metro endpoint
    1. Following the instructions in screencast #ws7, disable Reliability and enable Security on Metro endpoint and re-deploy.
    2. In the client project, select the first child node of "Web Service References", right-click and select "Refresh Client".
    3. In the "Confirm Client Refresh" window, select "Also replace local wsdl file with original WSDLs located at:" checkbox and click on "Yes".
    4. Right-click on the first child of "Web Service References" node, select "Edit Web Service Attributes" and select "Use development defaults". This will ensure that client and endpoint security credentials match.
    5. Expand "Source Packages", "META-INF" and open "HelloServiceService.xml". The name of this file is derived from the service name at the endpoint and may be different. Specify the location of trust store by adding the following attributes to "sc:KeyStore" element:

      location="C:\testbed\glassfish\final\glassfish\domains\domain1\config\cacerts.jks" type="JKS" storepass="changeit"

      The updated element looks like:

      <sc:TrustStore wspp:visibility="private" peeralias="xws-security-server" location="C:\testbed\glassfish\final\glassfish\domains\domain1\config\cacerts.jks" type="JKS" storepass="changeit"/>

      Make sure to match the value of location and password of the trust store in your environment.

    6. Right-click the client project and select "Run". This will build the project, invoke the endpoint and show the results in Output window as "Hello Duke".
    7. The SOAP messages during this run are now secured using the default security profile in NetBeans. The SOAP messages resemble as shown below:

      ====[com.sun.xml.ws.assembler.server:request]====
      <?xml version="1.0" ?>
      <S:Envelope
        xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
        xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
        xmlns:exc14n="http://www.w3.org/2001/10/xml-exc-c14n#">
        <S:Header>
          <To xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5006">http://localhost:8080/SEEndpoint/HelloServiceService</To>
          <Action xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5005">http://server/HelloService/sayHelloRequest</Action>
          <ReplyTo xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5004">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
          </ReplyTo>
          <MessageID xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5003">uuid:bb0e9571-a773-49bb-bad0-20a01d3af9f1</MessageID>
          <wsse:Security S:mustUnderstand="1">
            <wsu:Timestamp xmlns:ns10="http://www.w3.org/2003/05/soap-envelope" wsu:Id="3">
            <wsu:Created>2008-01-23T20:13:28Z</wsu:Created>
            ...

If you are using JDK version prior to Java SE 6 U4, then need to override the JAX-WS and JAXB API as described here. Java SE 6 U4 already includes JAX-WS and JAXB 2.1 APIs which are required for the Metro client to work.

Please leave suggestions on other TOTD that you’d like to see. A complete archive is available here.

Technorati: totd webservices metro glassfish netbeans javase

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

January 24, 2008

jMaki and Asynchronous Ajax @ Ajax World, New York 2008

Filed under: web2.0 — arungupta @ 11:00 pm
The jMaki session at the upcoming Ajax World East 2008 is featured on Web2Journal.

Enjoy several jMaki screencasts before the talk :)

Jean-Francois is also speaking on Asynchronous Ajax for Revolutionary Web Applications – He is a great speaker and interesting topic too!

If you want to speak, the Call For Paper for Ajax World closes tomorrow (Jan 25, 2008).

Technorati: conf jmaki ajaxworld web2journal

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

Little Rock National Airport Rocks – Free WiFi

Filed under: General — arungupta @ 5:02 pm

Little Rock National Airport literally rocks – Free WiFi all through out the terminal :)

Technorati: littlerock airport wifi traveltips

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

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