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.
- Following screencast #ws7, create a plain (without Security or Reliability enabled) Metro endpoint using NetBeans 6 and GlassFish v2.
- In NetBeans 6 IDE, install the JavaFX plugin as described here.
- 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.
- Create a new project of type "
Java Class Library" as shown below:

and click on "Finish".
- Enter the project name as "
MetroClientLibrary" as shown below:

and click on "Finish".
- Right-click on the newly created project, select "
New", "Web Service Client...".
- 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".
- 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.
- Create JavaFX project
- Create a new JavaFX project by right-clicking in the Project explorer, selecting "
New Project" and entering the values as shown below:

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

and click on "Finish".
- 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.
- 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;
&nb
sp; } catch (e:Exception) {
System.out.println("exception: {e}");
}
}
}
}
]
}
visible: true
};
- Invoke the JavaFX client project
- Right-click on the recently create project ("
MetroClient") and select "Run Project". The following window is displayed:

- 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
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:
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
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
: Mediacast deployment diagram is now available here.
Technorati: glassfish netbeans jruby rubyonrails mediacast stories
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
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

Technorati: conf jmaki jruby netbeans glassfish rubyonrails jruby jersey
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
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
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:
Let’s get started.
- Following screencast #ws7 create a plain (without Reliability and Security enabled) Metro endpoint.
- Create the Java SE client project
- In NetBeans IDE, create a new project of the type
Java/Java Application. Name the project as "SEClient" and take all other defaults.
- Right-click on the newly created project, select "
New", "Web Service Client...".
- Click on the "
Browse..." button next to "Project" radio button and select the deployed Web service endpoint.
- Enter the package name as "
client" and click on "Finish".
- Invoke the plain Metro endpoint
- 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".
- 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.
- Change the value of parameter "
name" to "Duke".
- 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".
- 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>
============
- Invoke the Reliable Metro endpoint
- Following the instructions in screencast #ws7, enable Reliability on Metro endpoint and re-deploy.
- In the client project, select the first child node of "
Web Service References", right-click and select "Refresh Client".
- In the "
Confirm Client Refresh" window, select "Also replace local wsdl file with original WSDLs located at:" checkbox and click on "Yes".
- 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".
- 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>
...
- Invoke the Secure Metro endpoint
- Following the instructions in screencast #ws7, disable Reliability and enable Security on Metro endpoint and re-deploy.
- In the client project, select the first child node of "
Web Service References", right-click and select "Refresh Client".
- In the "
Confirm Client Refresh" window, select "Also replace local wsdl file with original WSDLs located at:" checkbox and click on "Yes".
- 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.
- 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.
- 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".
- 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
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

Little Rock National Airport literally rocks – Free WiFi all through out the terminal
Technorati: littlerock airport wifi traveltips