The Source for Java Technology Collaboration
User: Password:



Bhakti Mehta's Blog

Web Services and XML Archives


Rehash of WS Reliable Messaging (WS-RM) in Metro 1.0 and what's next

Posted by bhaktimehta on September 18, 2007 at 10:59 AM | Permalink | Comments (4)

 Project Metro is a new name  for the JAX-WS + Project Tango combination. JAX-WS is the standardized web services stack
and Project Tango is the  Sun's Java Web Services interoperability project with
Microsoft's Windows Communication Foundation (WCF).

Project Metro is released and so is the  release of   GlassFish V2 FCS (b58g)
GlassFish V2 Embeds the Metro 1.0 Stack within it thereby making WebServices functionality directly
 usable from GlassFish (without the need for any extra downloads or installations).

WebServices Reliable Messaging (WS-RM)  is one of the enterprise features in  Project Metro.
Now we shall have a brief rehash of  WS-RM  in Metro 1.0 and what would be the new
features in upcoming releases

WS Reliable Messaging in Metro 1.0
WS-RM 1.0 is based on the following standards
The programming model when developing  webservices applications with Metro is the same old JAXWS Programming Model and
nothing new is required to be learned. 

Adding WS-RM, Security and other Quality of Service features to the  JAXWS webservice is enabled
via configuration files which can be handwritten or easily edited by Netbeans.
WS-RM is enabled in endpoints by the presence of RM policy assertions in the WSDL. Netbeans IDE will  provide
configurable settings to easily enable RM in endpoints.

Here is a brief overview of WS-RM. The tutorial provides detailed instructions on how to work with Metro.
This is a  screen cast which show how to easily enable WS-RM when working with Netbeans. For more information ,
instructions on how to use Netbeans with GF are also available here.

Future plans for WS Reliable Messaging 1.1
We have started working on these features on our trunk and you can get the latest nightly and try out and give us feedback at users@metro.dev.java.net .






Obtaining and analyzing thread dumps

Posted by bhaktimehta on May 25, 2007 at 01:09 PM | Permalink | Comments (4)

Most of us run into bugs where tests "hang". Here are some nice tools and tips I found to obtain and analyze thread dumps. I am sure there may be other tools so if you know of some good ones feel free to add.

Jstack
jstack prints Java stack traces of Java threads for a given Java process or core file or a remote debug server. However jstack is not available for Windows platforms or on the Linux platform.

Stacktrace
Stacktrace has great features which include
1. Thread dump for Java processes running as a Windows service (like Tomcat, for example), started with javaw.exe or embedded inside another process.
2. Thread dump for any applet running inside any browser (Apple, IBM and Sun JDKs for Windows and Mac OS X). StackTrace is known to work with IE, Firefox, Safari and Mozilla.
and many other features..


I usually get the java process id using jps

Control Break/ kill  options

On UNIX platforms you can send a signal to a program by using the kill command. This is the quit signal, which is handled by the JVM. For example, on Solaris you can use the command kill -QUIT process_id,
where process_id is the process number of your Java program.

Alternatively you can enter the key sequence <ctrl>\ in the window where the Java program was started. Sending this signal instructs a signal handler in the JVM, to recursively print out all the information on the threads
and monitors inside the JVM.
To generate a stack trace on Windows platforms, enter the key sequence <ctrl><break> in the window where the Java program is running, or click the Close button on the window.

Byron Nevins has also pointed in his blog how to obtain thread dumps in Glassfish.

TDA
This is a great utility I found for analyzing thread dumps.

I especially liked the ability to filter the threads display to be able to ignore e.g. idle threads.. Also as you can see in Fig 1 The three pane view is really helpful

tda.jpg Fig 1 : Using TDA to analyze thread dumps



Update to Developing Webservices using Glassfish AS 9.1 and JDK 6

Posted by bhaktimehta on January 24, 2007 at 12:10 PM | Permalink | Comments (1)

In the previous  blog  we tried running glassfish-samples using Glassfish v2  using JDK 6.
We walked through what was different when trying with JDK 6 and I mentioned to use a temporary
work-around of putting javaee.jar in $AS_HOME/lib/endorsed..
However this bug is now fixed since Glassfish v2 b31 .

The latest Glassfish v2 installs webservices-api.jar in $AS_HOME/lib/endorsed. and hence we do not need to put javaee.jar there.


So here is the updated blog.

Steps to run the sample with JDK 6

Install JDK 6 from http://download.java.net/jdk6/binaries/

Install  GlassFish v2

You can install  the latest nightly or the latest promoted v2 build from https://glassfish.dev.java.net/public/downloadsindex.html
Follow these instructions to unbundle and configure glassfish .

Check the version of JDK used by Glassfish to be JDK 6.0

For those users who have already installed GlassFish and wish to change the JDK version. That's equally simple. The JDK path is stored in one location :
  1. Check the following file where AS_HOME is the location where Glassfish is installed
    <$AS_HOME>/config/asenv.conf for AS_JAVA
  2. Modify  $AS_JAVA to point to JDK 6 if that is not already set
    AS_JAVA="location of JDK 6" 

Download the  glassfish-samples from the following site https://glassfish-samples.dev.java.net/

  1. Run :
     java -jar javaee5-samples-installer-1.0-b09.jar
  2. Edit : <location of samples>/bp-project/build.properties to point to $AS_HOME for e.g
      javaee.home="location of Glassfish"
  1. Check the java version on the client side
      /usr/glassfish-samples/javaee5/webservices %java -version
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)

Start Appserver
/usr/glassfish/bin %$AS_HOME/bin/asadmin* start-domain domain1


Run the Sample
  1. /usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant
  2. This is how the output looks like on the client side
/usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant
Buildfile: build.xml

init:

compile-deploy-service:
     [echo] /usr/glassfish

get-artifacts-unix:
     [exec] parsing WSDL...

     [exec] generating code...

get-artifacts-windows:

get-artifacts:

compile-client:
    [javac] Compiling 1 source file to /usr/glassfish-samples/javaee5/webservices
hello-jaxws/build

run-client-unix:
     [exec] Hello result = Hello Administrator!

run-client-windows:

run-client:

all:

BUILD SUCCESSFUL
Total time: 13 seconds


Please note:
As seen in the following sample.
Clients should set the fololowing property to run with JDK 6

 <sysproperty key="java.endorsed.dirs" value="${javaee.home}/lib/endorsed"/> 

Also for ant tasks like wsimport,xjc :

The solution is to copy $AS_HOME/lib/endorsed/webservices-api.jar to $JAVA_HOME/jre/lib/endorsed.

Neither jvmargs nor sysproperty will work in this case
because by the time ant loads this class it would have already loaded the 2.0 classes
and we did not get the chance to override the 2.0 classes with 2.1 classes.

Developing Webservices using Glassfish AS 9.1 and JDK 6

Posted by bhaktimehta on January 02, 2007 at 11:08 AM | Permalink | Comments (2)

Developing Webservices using Glassfish AS 9.1 and JDK 6

This blog will show how to develop, run and deploy JAX-WS  based webservices with Glassfish v2 Milestone 3 build using JDK 6.
It will demonstrate step by step instructions using the hello-jaxws sample from the following glassfish-samples.

What is different when trying with JDK 6?

JDK 6.0 has  JAXB/JAX-WS 2.0 versions of the apis.
In the latest Glassfish v2 we are integrating the implementation classes compliant with JAXB/JAX-WS 2.1 versions
of the apis which are present in  javaee.jar .

So when we run with Glassfish and JDK 6.0 (without putting anything in the <AS HOME>/lib/endorsed directory),
the APIs/Annotation classes for JAX-WS 2.0 and JAXB 2.0 will be picked up instead of JAX-WS 2.1 and JAXB 2.1.

To avoid this we need to use the endorsed standards to override the 2.0 apis by putting javaee.jar in $AS_HOME/lib/endorsed.
This is a temporary workaround for now and this issue will be fixed soon.

Steps to run the sample with JDK 6

Install JDK 6 from http://download.java.net/jdk6/binaries/

Install  GlassFish v2 Milestone 3

Install  from https://glassfish.dev.java.net/public/downloadsindex.html
Follow these instructions to unbundle and configure glassfish .

Check the version of JDK used by Glassfish to be JDK 6.0

For those users who have already installed GlassFish and wish to change the JDK version. That's equally simple. The JDK path is stored in one location :
  1. Check the following file where AS_HOME is the location where Glassfish is installed
    <$AS_HOME>/config/asenv.conf for AS_JAVA
  2. Modify  $AS_JAVA to point to JDK 6 if that is not already set
    AS_JAVA="location of JDK 6" 

Download the  glassfish-samples from the following site https://glassfish-samples.dev.java.net/

  1. Run :
     java -jar javaee5-samples-installer-1.0-b08.jar
  2. Edit : <location of samples>/bp-project/build.properties to point to $AS_HOME for e.g
     javaee.home="location of Glassfish"
  3. Check the java version on the client side
     /usr/glassfish-samples/javaee5/webservices %java -version
           java version "1.6.0-rc"
           Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
           Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode,   sharing)

Add javaee.jar to $AS_HOME/lib/endorsed

As mentioned earlier this extra step will be required for running with JDK 6.0

  1. mkdir -p $AS_HOME/lib/endorsed
  2. mv $AS_HOME/lib/javaee.jar $AS_HOME/lib/endorsed
Start Appserver
/usr/glassfish/bin %$AS_HOME/bin/asadmin* start-domain domain1


Run the Sample
  1. Modify <location  of samples>/javaee5/webservices/hello-jaxws/build.xml to point to
    $AS_HOME/lib/endorsed/javaee.jar in classpath. Currently the samples point to j2ee.jar in the build.xml
  2. Replace references of j2ee.jar with location of javaee.jar
    <path id="classpath">
        <pathelement location="${javaee.home}/lib/endorsed/javaee.jar"/>
        <pathelement location="${classesdir}"/>
    </path>

    and
    <target name="compile-deploy-service" depends="init">
    <mkdir dir="${classesdir}"/>
    <echo message="${javaee.home}"/>
    <javac
    srcdir="./src"
    includes="endpoint/**"
    destdir="${autodeploydir}"
    classpath="${javaee.home}/lib/endorsed/javaee.jar"
    />
    ...
    </target>


  3. Run:
    /usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant

This is how the output looks like on the client side
/usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant
Buildfile: build.xml

init:

compile-deploy-service:
     [echo] /usr/glassfish

get-artifacts-unix:
     [exec] parsing WSDL...

     [exec] generating code...

get-artifacts-windows:

get-artifacts:

compile-client:
    [javac] Compiling 1 source file to /usr/glassfish-samples/javaee5/webservices
hello-jaxws/build

run-client-unix:
     [exec] Hello result = Hello Administrator!

run-client-windows:

run-client:

all:

BUILD SUCCESSFUL
Total time: 13 seconds












WS-Reliable Messaging and Session Support (Part2)

Posted by bhaktimehta on August 21, 2006 at 03:29 PM | Permalink | Comments (0)

This is Part 2 in a series of articles on supporting sessions using WS-ReliableMessaging. In this blog Mike Grogan compares HttpSessions and ReliableSessions and demonstrates the problems with the approach taken in Part 1

Technorati:

WS Reliable Messaging and Session Support (Part1)

Posted by bhaktimehta on August 02, 2006 at 02:31 PM | Permalink | Comments (1)

WS Reliable Messaging and Session Support This sample was shown as a demo in the session "Reliable and Transacted Web Services between
Java™ Technology-Based Project Tango and Microsoft Indigo" TS-1603 at  Javaone 2006.

This is a part of tri series blogs where in Part 1 we will show one way of supporting sessions with
WS Reliable Messaging. Then Mike will show in his blog what are the problems with this approach and we will
conclude with a third part where we have tried to fix some of these problems .

Sessions are unique ids used to identify a client. They would help maintain state for each client.
In this sample you will see how sessions can be supported with WS Reliable Messaging (WS RM) .
WS RM  is one of the enterprise features in Project Tango which is Sun's Java Web Services
interoperability project with Microsoft's Windows Communication Foundation (WCF).

The following snippets of code show how the JAX-WS Endpoint implementation which is RM enabled
supports sessions .

This is the wsdl which shows RM is enabled in the endpoint by the presence of WS-RM Policy Assertions.
Here is endpoint implementation class
@WebService(endpointInterface="rmdemo.server.RMDemo")

public class RMDemoImpl {

....

}

We create a HashTable of  SessionIds  as the keys and Strings which are entered by the clients as the values.
private final HashTable<String,String> sessionTable = 
    new HashTable<String, String>();

JAX-WS uses annotations defined by Common Annotations for the Java Platform (JSR 250),
to inject the Web ServiceContext and declare lifecycle methods. Web ServiceContext holds the
context information pertaining to a request being served. With JAX-WS Web Service all you need to do is
mark a field or method with @Resource.  From the WebServiceContext,  MessageContext pertaining
to the the current request can be accessed. More information on how MessageContext  can be used to
share metadata is explained in this article.

  @Resource
  private javax.xml.ws.WebServiceContext context;

As mentioned above WebServiceContext exposes  the MessageContext  for the request being served when this method is called .
The session id is obtained from the MessageContext using a jax-ws property "com.sun.xml.ws.sessionid"

  private String getSessionId() {
      return (String)context.getMessageContext()
      .get("com.sun.xml.ws.sessionid");
  }


The following getter  method returns the String associated with each request . Correspondingly the setter method 
stores the Strings for each session in the HashTable respectively.

 private String getSessionData() {
      String id = getSessionId();
      String ret = sessionTable.get(id);
      return ret!= null ? ret : "";
  }

  private void setSessionData(String data) {
       sessionTable.put(getSessionId(), data);
  }

These addString method and getResult method are exposed by our RM endpoint. The method addString  takes a
String as entered by a user and adds it to the Strings stored in the session data for that session.
The getResult will return all the strings entered by the user during that session.

  @WebMethod
  public void addString(String s )       setSessionData(getSessionData() + " " + s);

  }

  @WebMethod
  public String getResult() {
       return getSessionData(); 

  }
This example is a good demonstration of how InOrder delivery assurance (i.e messages are delivered in
the order that they are sent)  in WS Reliable Messaging works. If the ordered delivery would not work
right then the strings stored in the session would not have been in the right order.
Full source code for the RMDemoImpl.java  is here.

Client Code
Here is the source code for the client. The client enters  various input Strings and finally hits carriage
return to terminate the client application and all the Strings received so far for that client will be returned by the
server.

Sample will be bundled in the samples folder.

Instructions to run the sample

Please follow the Readme to setup and run the sample.

For any questions or feedback on the sample please write to users@wsit.dev.java.net

Additional sources of information

WSIT website
Check this website for latest source code, samples,documentation

Project GlassFish Open Source App Server
All WSIT technologies can be installed on this FREE app server

Netbeans IDE Module:
All WSIT technologies available today can be configured visuall using this Netbeans module.

Slides for TS 1603
Reliable and Transacted Web Services between Java™ Technology-Based Project Tango and Microsoft Indigo
 at Javaone 2006
WS-ReliableMessaging specification

Maintaining Session With JAX-WS












JAXB 2.0 and JAX-WS 2.0 are a part of Mustang (JDK 6.0)

Posted by bhaktimehta on August 08, 2005 at 04:18 PM | Permalink | Comments (2)

Delivering Web Services is one of the primary themes for Mustang (Java SE 6). Our goal is that JSE will provide reasonable support for ease of development for the web services stack. This will primarily be client-side focused with a lightweight server to support callbacks. The main specifications are the Java Architecture for XML-Web Services (JAX-WS) 2.0 (formerly known as JAX-RPC) and Java Architecture for XML Binding (JAXB) 2.0.

JSR 224 is defining JAX-WS 2.0. This is a major update since the JAX-RPC 1.0 specification incorporating new specifications and updates to existing standards. JAX-WS 2.0 now delegates the databinding related tasks to JAXB 2.0.

JSR 222 is defining JAXB 2.0. It adds significantly to JAXB 1.0, including 100% XML schema support, the binding of Java classes to XML schema, the meeting of data binding requirements for JAX-WS 2.0, and schema evolution support. A flexible binding allows an application to bind only parts of an XML document (relevant to the application) to Java.

Mustang has the webservices features integrated as of b40. You can try the latest snapshot from https://mustang.dev.java.net/

We are fixing and integrating bugs on a regular basis. Please let us know about your bugs, you can file them at
http://bugs.sun.com/bugdatabase/index.jsp

There are 4 new scripts added in the jdk6.0/bin which are as follows xjc, schemagen , wsimport and wsgen
To run the JAXB schema compiler you can invoke the xjc as

/path/to/jdk6.0/bin/xjc foo.xsd -p test.foo

Similarly to invoke the schema generator to generate schemas from Java sources

/path/to/jdk6.0/bin/schemagen Foo.java

To generate portable artifacts from wsdls and external jaxws or jaxb binding files you can use wsimport

/path/to/jdk6.0/bin/wsimport stock.wsdl -b stock.xml -b stock.xjb

To generate portable artifacts from Java sources you can use wsgen

/path/to/jdk6.0/bin/wsgen example.Stock

Javadocs for jdk6.0
The javadocs are located at
http://www.java.net/download/jdk6/doc/api/

Forums
http://forums.java.net/jive/forum.jspa?forumID=25

List of Committed bugs in the latest snapshot release
https://mustang.dev.java.net/MustangCommittedBugs.html

More information on JAXB and JAXWS

* JAXB
* JAXWS





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds