<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title> Binod&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/" />
<modified>2008-06-12T13:37:54Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/binod/273</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, binod</copyright>
<entry>
<title>SailFin work and BTrace</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2008/06/sailfin_work_an.html" />
<modified>2008-06-12T13:37:54Z</modified>
<issued>2008-06-12T13:37:38Z</issued>
<id>tag:weblogs.java.net,2008:/blog/binod/273.9959</id>
<created>2008-06-12T13:37:38Z</created>
<summary type="text/plain">This blog explains how I used btrace to track some of the complex issues we found during sailfin work. </summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>Lately I have been a spending significant amount of time analyzing issues coming from sailfin <a href="http://blogs.sun.com/bharath/">performance team</a> and <a href="http://blogs.sun.com/sonymanuel/">system testing team</a>. One of them was particularly tricky. Testing team was running a test 24x7 on a 10 instance sailfin cluster with CLB etc. There were 5 odd machines running many <a href="http://sipp.sourceforge.net/">sipp</a> clients pumping traffic to the <a href="http://sailfin.dev.java.net">sailfin</a>. They started observing a memory leak and I went about debugging it. 
</p>
<p>jmap they produced (huge.. in GBs) showed the possibility of a leak of SipSession objects. </p>
<p>
The problem with some memory leaks at times is the difficulty to confirm that the leak is in a particular data structure in a particular part of the code. Here also the case was the same.</p>
<p>
So, I took the help of <a href="http://btrace.dev.java.net">btrace</a>.
</p><p>
I wrote a  btrace script, without much difficulty. I ran the server under load for quite some time and then stopped the traffic so that SipSessions gets cleaned up. Then attached the btrace script to the running java process. I didnt have to compile the script just used the java file directly.
</p><p>
Here is the script, ConcurrentHashMap.java </p><p>
<pre>package com.sun.btrace.binod;

import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
import java.lang.reflect.Field;

@BTrace public class ConcurrentHashMapTrace {

  @OnMethod(
    clazz="java.util.concurrent.ConcurrentHashMap",
    method="put"
  ) 
  public static void onPut(java.util.concurrent.ConcurrentHashMap me, Object key, Object value) {
    //toString() of SipSessionDialogImpl contains the string SipSession.
    if (indexOf(str(value),"SipSession") > -1) {
        println(value);
        println(size(me));
    }
  }
}</pre>
</p><p>
Then I ran the command : <i>btrace &lt;pid&gt; ConcurrentHashMapTrace.java.</i>
This attaches our btrace script to the JVM and waits.
</p><p>
And then sent just one INVITE message to the server. Btrace script printed the size of the concurrenthashmap that hold the sessions and it was more than I expected. That confirms the leak. I also used modified versions of the script to make sure that there is no other related object leak (eg: SipApplicationSessions).
</p><p>
After figuring out where the leak is, it was a matter of code inspection, further debugging and then <a href="https://sailfin.dev.java.net/servlets/ReadMsg?list=cvs&msgNo=4849">checking in the fix</a>..
</p><p>
Next, I am trying to see if System.gc is ever called during the test run so that we can try removing DisableExplicitGC flag from GC settings. Another btrace script....</p>]]>

</content>
</entry>
<entry>
<title>SailFin at JavaOne</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2008/05/sailfin_at_java_1.html" />
<modified>2008-05-07T02:11:07Z</modified>
<issued>2008-05-07T02:10:59Z</issued>
<id>tag:weblogs.java.net,2008:/blog/binod/273.9718</id>
<created>2008-05-07T02:10:59Z</created>
<summary type="text/plain">Here are the details of sailfin activities at JavaOne 2008.</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>Tomorrow (Wednesday) morning at 9.30am, me and  <a href="http://www.ericsson.com/mobilityworld/sub/articles/other_articles/080428_gronowski">Kristoffer</a> talk about <i><a href="http://sailfin.dev.java.net">SailFin</a> architecture</i>. The Venue is Hall E 134. This session gives the details about the project architecture, features and roadmap. Kristoffer and Ola have another session on Friday at 12.10 about </i> End to End Communication Services with Java ME and Java EE. </i> This is at Esplanade 303.</p>

<p>There is a hands on lab that demonstrates how to develop applications on <a href="http://sailfin.dev.java.net">SailFin</a>. This is at 9.30am on Thursday at Hall E 130/131.</p>

<p>Then there is another hands on lab that shows performance analysis of SIP applications. This is at 1.00pm on Thursday, again at Hall E 130/131.</p>

<p>Many developers and architects from Sun and Ericsson are available in the <a href="http://sailfin.dev.java.net">SailFin</a> booth in the Pavilion. Please do come and meet us!</p>

<p>FInally.... There is a  <a href="http://java.sun.com/javaee/community/campaigns/sun_ericsson-052008/welcome.jsp?">Sun-Ericsson Application Competition</a> that is launched this week. Please participate to win $5000 or a Sony Ericsson Phone.</p>]]>

</content>
</entry>
<entry>
<title>Locating SIP servers using DNS in SailFin</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2008/02/using_dns_serve.html" />
<modified>2008-02-22T10:58:35Z</modified>
<issued>2008-02-22T10:58:06Z</issued>
<id>tag:weblogs.java.net,2008:/blog/binod/273.9249</id>
<created>2008-02-22T10:58:06Z</created>
<summary type="text/plain">A few months back, we enabled the ability to resolve Sip URIs using DNS in SailFin. This is based on RFC 3263. Lets discuss how DNS can be used to determine both protocol and port number of a UAS from sailfin.</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>As per RFC 3263, there are two new kind of records that are important for SIP. They are Naming Authority Pointer (<a href="http://tools.ietf.org/html/rfc3403">NAPTR</a>) Record and Service Record (<a href="http://www.ietf.org/rfc/rfc2782.txt">SRV</a>). In this example, NAPTR is used as a mechanism to specify the protocol (TCP or UDP) where as SRV records will be used locate the server and port from <a href="http://sailfin.dev.java.net">SailFin</a>.</p>

<p><b>Example snippet from DNS zone file</b></p>

<pre>
_sip._udp.test.com. 3600 IN SRV 10 0 5090 sailfinserver.test.com.
_sip._tcp.test.com. 3600 IN SRV 10 0 5090 sailfinserver.test.com.
_sips._tcp.test.com. 3600 IN SRV 10 0 5061 sailfinserver.test.com.
_sips._udp.test.com. 3600 IN SRV 10 0 5061 sailfinserver.test.com.
</pre>
<pre>
;                  order pref flags service      regexp  replacement
test.com. IN NAPTR 0 0 "s" "SIPS+D2T" "" _sips._tcp.test.com.
test.com. IN NAPTR 1 0 "s" "SIP+D2T"  "" _sip._tcp.test.com.
test.com. IN NAPTR 2 0 "s" "SIP+D2U"  "" _sip._udp.test.com.
</pre>
<pre>
sailfinserver.test.com. IN A 192.168.1.100
</pre>
Lets take the NAPTR record shown above, the third column, in these records suggest that the server support TLS over TCP, TCP and UDP protocols and are preferred in that order. Now, if the client support TCP and UDP, then the preference will be given to TCP as that has the lower order compared to UDP.

<p>The SRV records suggest that the port used by the server for TCP and UDB communication is 5090 and not the usual 5060 and the actual server is <i>sailfinserver.test.com</i>.</p>

<p>Finally we have an A record that resolves the <i>sailfinserver.test.com</i> to the computer's IP address.</p>

<p>SailFin uses <a href="http://sailfin.dev.java.net">dnsjava</a> apis for name resolution. It allows the user to configure a JVM option called dns.server for specifying the name server. We could specify that as a jvm-option in domain.xml </p>

<p><img alt="dns-jvmoption.png" src="http://weblogs.java.net/blog/binod/archive/dns/dns-jvmoption.png" width="312" height="26" /></p>

<p>If this is not specified, dnsjava also searches /etc/resolve.conf to find the name server. For experimenting that was better for me, as I always have a local name server running in the laptop. (For a moment forget Sip/SailFin, local name server (bind) performs much better for me than <a href="http://www.bsnl.co.in/service/dataone.htm">BSNL</a> or opendns. That itself is a reason to run a local name server).</p>

<p>Here is my /etc/resolve.conf file content.</p>

<p>nameserver 127.0.0.1<br />
nameserver 218.248.240.208<br />
nameserver 4.2.2.1</p>

<p>Once these are configured, SailFin will be able to resolve the domain "test.com" and find correct SIP server, protocol, port etc. Here is the example of the INVITE message that I tried.</p>

<p><img alt="dns-invite.png" src="http://weblogs.java.net/blog/binod/archive/dns/dns-invite.png" width="404" height="257" /></p>

<p>With these settings, SailFin will resolve "To" address to 192.168.1.100:5090 and will use TCP protocol.</p>]]>
<![CDATA[<p>I have <a href="http://weblogs.java.net/blog/binod/archive/dns/dns-sailfin.zip">uploaded</a> the following files in a zip, as an example.</p>

<p>1. sip-proxy.war : A sip application as explained in <a href="http://wiki.glassfish.java.net/Wiki.jsp?page=SipServletProxyExample">Sip Proxy example</a> of sailfin. <br />
2. xyz.zone which contains all the DNS records explained above.<br />
3. named.conf of my bind DNS.<br />
4. uac.xml and uas.xml files for running the sipp tests (I have hard coded the test.com in the files)</p>

<p><b>Steps to try DNS in sailfin.</b></p>

<p>1. Setup and start the nameserver (bind). The example zip file contains named.conf and the domain zone file.<br />
2. After starting the DNS, dig it and see, if it is working (eg: <i>dig @127.0.0.1 NAPTR test.com</i>). Make sure that the ANSWER from DNS contains the SRV records.<br />
3. Configure either the dns.server jvm-option in sailfin or /etc/resolve.conf<br />
4. Start a SailFin server and deploy the sip proxy servlet.<br />
5. Use Sipp to execute a proxy scenario using the uac.xml and uas.xml. (The only change from the proxy example will be to use the sip proxy files. </p>]]>
</content>
</entry>
<entry>
<title>JBI in GlassFish</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2006/12/jbi_in_glassfis.html" />
<modified>2006-12-28T12:29:34Z</modified>
<issued>2006-12-28T12:29:15Z</issued>
<id>tag:weblogs.java.net,2006:/blog/binod/273.6218</id>
<created>2006-12-28T12:29:15Z</created>
<summary type="text/plain">A JBI runtime has been integrated with glassfish V2. This is the same JBI runtime
that was available as part of open-esb project. Currently it is also available
as an addon in Java Application Platform SDK. However with this integration, it
is by default available with GlassFish V2 installation.</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>A <a href="http://en.wikipedia.org/wiki/Java_Business_Integration">JBI</a> runtime has been <a href="http://www.glassfishwiki.org/jbiwiki/Wiki.jsp?page=GlassfishJbiIntegration">integrated</a> with glassfish V2. This is the same JBI runtime that was available as part of <a href="https://open-esb.dev.java.net/">open-esb</a> project. Currently this is also available as an addon in <a href="http://java.sun.com/javaee/downloads/index.jsp">Java Application Platform SDK</a>. However with this integration, it is by default available with GlassFish V2 installation.</p>

<p>A lot of work happened in GlassFish V2 for integrating JBI. Mainly these are in the areas of administration, clustering and runtime. Two JBI components (<a href="http://www.glassfishwiki.org/gfwiki/Wiki.jsp?page=JavaEEServiceEngine">Java EE Service Engine</a> and <a href="http://www.glassfishwiki.org/jbiwiki/Wiki.jsp?page=HTTPBC">HTTP/SOAP Binding component</a>) also will be available in GlassFish as system components.<br />
<u><br />
<strong>Administration Experience</strong></u></p>

<p>Apart from all the tools that was available in earlier JBI runtime, now it can be administered using Glassfish's own asadmin command line interface. See below <a href="http://blogs.sun.com/janeyoung/">Jane</a>'s CLI <a href="http://blogs.sun.com/janeyoung/entry/finding_cli_commands_in_glassfish">command finder </a>suggesting a number JBI commands.</p>

<p><img alt="jbi-cli.png" src="http://weblogs.java.net/blog/binod/archive/jbi-cli.png" width="1024" height="768" /></p>

<p>A complete list of commands and more details are available in <a href="http://www.glassfishwiki.org/jbiwiki/Wiki.jsp?page=Glassfish9.1JBICLIProjectPlan">JBI wiki page</a>. GlassFish GUI has the capability to manage the JBI artifacts also. The picture shows a snapshot I took some time back.</p>

<p><img alt="jbi-console.png" src="http://weblogs.java.net/blog/binod/archive/jbi-console.png" width="1024" height="768" /></p>

<p>Apart from these, composite applications (service assemblies) can be dropped in to autodeploy folder of the GlassFish application server and they will be deployed into the JBI runtime in appserver.</p>

<p><u><strong>Clustering</strong></u></p>

<p>JBI runtime has been enhanced to adhere to the <a href="http://www.glassfishwiki.org/gfwiki/Wiki.jsp?page=GlassFishV2Architecture">appserver clustering architecture</a>. Each instance in the appserver cluster will also have a JBI runtime in it. That means a JBI component or service assembly can be deployed to the GlassFish appserver cluster. It will be activated dynamically in each server instance. The components (similar to java ee containers) should implement their own load balancing and high availability mechanism. There are a number of <a href="http://www.glassfishwiki.org/jbiwiki/Wiki.jsp?page=Jbicomps">components</a> that are being developed as part of this <a href="https://open-jbi-components.dev.java.net/">open source project</a>.<br />
<u><br />
<strong>Runtime</strong></u></p>

<p>JBI is integrated with appserver as a pre-configured <a href="https://glassfish.dev.java.net/javaee5/docs/DG/beamc.html">lifecycle</a> module. That means whenever an appserver instance starts up, the JBI runtime will be available. There is no user interaction required to configure or start the JBI runtime. It is just like any other service of appserver.</p>

<p><a href="http://www.glassfishwiki.org/gfwiki/Wiki.jsp?page=JavaEEServiceEngine">Java EE Service Engine</a> act as the bridge between Java EE applications and JBI. A number of enhancements and performance improvements has been implemented in the Java EE Service Engine.</p>

<p>A Java EE application archive (ear/war/jar) can be packaged in a JBI composite application and deployed as one single entity.</p>

<p>Service units belonging to other JBI components and Java EE applications can share the same transaction and security contexts.</p>

<p><u><strong>Summary</strong></u></p>

<p>From user's point of view, glassfish now supports JBI. It means that glassfish now supports composite applications (Service assemblies) and a Java EE application can be part of one such composite application. A host of netbeans based tools and other JBI components will be available. So, application integration is made simpler (I know, still it is a big challenge).</p>

<p>For more information take a look at <a href="http://www.glassfishwiki.org/gfwiki/attach/UserExperienceMeeting/gfv2-jbi-integration.pdf">user-experience</a> presentation slides and one pager. Also <a href="http://www.glassfishwiki.org/jbiwiki/">JBIWiki</a> has a host of JBI related information.</p>

<p>Enjoy GlassFish!</p>]]>

</content>
</entry>
<entry>
<title>GlassFish and Windows Firewall</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2006/12/glassfish_and_w.html" />
<modified>2006-12-08T17:57:54Z</modified>
<issued>2006-12-08T17:57:43Z</issued>
<id>tag:weblogs.java.net,2006:/blog/binod/273.6128</id>
<created>2006-12-08T17:57:43Z</created>
<summary type="text/plain">We, glassfish engineering team, often get issues related to windows firewall settings and its impact on socket mechanism in glassfish. This entry describles some of those issues</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>One of my Sun collegues (<a href="http://blogs.sun.com/bobby/">Bobby</a>) noticed that glassfish web server stops responding soon after the startup. The most interesting thing he found was that he can access the webserver using http://localhost:8080 where as accessing it using IP address (http://x.x.x.x:8080) wasnt working. The plot thickened when we found that the webserver can be accessed once using the IP address and from second time onwards it started failing. Two web browsers and a wget.exe showed the same behaviour.</p>

<p>Bobby is located in Santa Clara and I am located in Bangalore office of Sun Microsystems. Bobby setup a VNC Server on the laptop during his night so that I can look at whats happening during my day. Global engineering certainly certainly has advantages :-)</p>

<p>Debugging spell was quite longer than usual. Finally, we found that the issue was because of a firewall setting in the norton windows firewall. </p>

<p>As explained <a href="http://service1.symantec.com/SUPPORT/sunset-c2002kb.nsf/29dd58255a9a57a585256ee600556cc1/ade2747ea2a9741685256ede00518db1?OpenDocument">here</a> symantec firewall has a setting called "Default Inbound loopback" which is configured to allow only 127.0.0.1. When this configuration is changed to allow any IP address (well bobby was using DHCP) the server started working.</p>

<p>This is not the first firewall related issue glassfish team has faced. Another one is with the Windows java.nio Selector implementation. Windows selector implementation in JDK use a loopback socket to handle the wakeup mechanism. But some firewalls are particularly strict against loopback sockets. Typically the issue will surface with the following stacktrace</p>

<pre>
java.io.IOException: Unable to establish loopback connection
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:106)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:122)
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:27)
</pre>

<p>There are so many reports about this issue. Here are some links where people faced it outside glassfish [<a href="http://mail-archives.apache.org/mod_mbox/directory-dev/200505.mbox/%3C29b24116e9df8638457544d994f5f369@pegacat.com%3E">apache</a>, <a href="http://www.gnutellaforums.com/showthread.php?t=52960">limeware</a>] </p>

<p>A neat explanation about this issue can be found in this sun <a href="http://forum.java.sun.com/thread.jspa?threadID=579675&messageID=2940535">forum link</a> on socket programming.</p>

<p>Thats all for today. Now that I have started working from home for 2 days a week, hopefully I will get time to write next blog soon.</p>

<p>Thanks to Bobby for his excellent support on debugging some of these issues.</p>]]>

</content>
</entry>
<entry>
<title>GlassFish@Foss.IN</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2006/11/glassfishfossin_1.html" />
<modified>2006-11-24T06:10:15Z</modified>
<issued>2006-11-21T18:05:46Z</issued>
<id>tag:weblogs.java.net,2006:/blog/binod/273.6011</id>
<created>2006-11-21T18:05:46Z</created>
<summary type="text/plain">The year 2006 edition of foss.in is happening this weekend (November 24, 25 and 26).</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>At <a href="http://en.wikipedia.org/wiki/Indian_Institute_of_Science">Indian Institute of Science</a>, a prestigious educational institution in Bangalore, year 2006 edition of the <a href="http://foss.in">http://foss.in</a> will be held. GlassFish will have significant presence this time (November 24, 25 and 26) also. <a href="http://blogs.sun.com/prsad/">Prasad</a> is giving a talk on Project GlassFish, its current status, roadmap, new features, cool things etc. This will happen on Saturday, November 25. </p>

<p>The Sun booth will demonstrate a Java EE 5 application getting developed on netbeans and deployed on GlassFish. We had a dry run of the app (<a href="http://weblogs.java.net/blog/ss141213/">Sahoo</a> wrote it) at Sun campus this week and it is indeed a nice and simple explanation of what netbeans and glassfish is capable of.</p>

<p>Come, interact with the GlassFish engineers in the booth and pick up a glassfish CD.</p>

<p>For those who are interested in what foss.in is all about, see the event <a href="http://foss.in/2006/info/Event_History">history</a>. </p>

<p>Updates:</p>

<p>Sahoo blogged about the <a href="http://weblogs.java.net/blog/ss141213/archive/2006/11/welcome_to_glas.html">demo</a>. Take a look.</p>

<p>Siva and Prasad has blogged [<a href="http://blogs.sun.com/sivakumart/entry/glassfish_at_foss.in_2006">1</a>, <a href="http://blogs.sun.com/prsad/entry/glassfish%40foss.in_2006">2</a>] about the event also.</p>]]>

</content>
</entry>
<entry>
<title>Java EE Service Engine: Bridging Java EE and JBI</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2006/07/java_ee_service_1.html" />
<modified>2006-07-10T10:20:19Z</modified>
<issued>2006-07-10T10:20:03Z</issued>
<id>tag:weblogs.java.net,2006:/blog/binod/273.5165</id>
<created>2006-07-10T10:20:03Z</created>
<summary type="text/plain">For some time now, I have been thinking about writing about some use cases of Java EE service engine, explaining how it bridges Java EE and JBI. This blog explains a composite application, whose main entry point is an MDB. Towards the end of the blog, some details of the implementation is also provided.</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>In a typical Java EE application, MDBs are used to listen to messages from the external systems and act as integration point between two systems. Wouldnt it be good, if that MDB become part of a composite application and thus leverage full capability of JBI also? The example composite application below explains how a BPEL app is accessed from MDB. To keep the things simple (unfortunately composite applications are not simple...) the BPEL sample accesses only a Java EE webservice (SLSB). BPEL is extremely powerful and to know how more about that, read <a href="http://blogs.sun.com/roller/page/gopalan?entry=about_me">Gopalan</a>'s <a href="http://blogs.sun.com/roller/page/theaquarium?entry=learning_bpel_blogs_by_gopalan">blogs</a>.</p>

<p>Ok, enough of theory, lets get into some action. Below is the architecture diagram of an example application.</p>

<p><img alt="javaeese.png" src="http://weblogs.java.net/blog/binod/example/javaeese.png" width="833" height="488" /></p>

<p>As explained in the diagram, the client application sends a message to the Queue which is picked up by the MDB. Upon receiving that message, by using the Java EE Service Engine, the MDB contacts the JBI NMR for the service endpoint exposed by the BPEL process. When MDB executes the BPEL application (hosted by BPEL service engine) BPEL app will contact JBI NMR for finding its partner services. In our BPEL example, there is only one partner service and it is a stateless session bean (JSR 109 webservice) hosted in the same appserver JVM. The JSR 109 webservice's endpoint is enabled in JBI NMR by Java EE Service Engine when the stateless session bean gets deployed. This SLSB uses new Java EE persistence apis to access the database.</p>

<p>In fact, Java EE SDK and Netbeans Enterprise Pack hides many complexities from the developer. Thus a developer's view of the composite application is much simple and as given below. I just hid engines and NMR and made a simpler diagram.</p>

<p><img alt="javaeese-app.png" src="http://weblogs.java.net/blog/binod/example/javaeese-app.png" width="858" height="483" /></p>

<p>As explained in the diagram above, the MDB just uses JAXWS client apis to access the BPEL process. The BPEL process then invokes the Java EE webservice. The SLSB(Java EE webservice) uses persistence API to access the database. So, a developer just need to code the MDB, the stateless session bean and persistence code and design a BPEL process using these in the BPEL designer. </p>

<p><u>Now, lets see some real code</u>. To focus on our topic, I am just concentrating on the plumbing part. </p>

<p><u>Step-1</u></p>

<p>Develop a SLSB called StockWS. Annotate it with @Webservice to make it a JSR 109 webservice. See the code snippet below.</p>

<p><img alt="slsb-ws.png" src="http://weblogs.java.net/blog/binod/example/slsb-ws.png" width="876" height="494" /></p>

<p>Deploy the service to the application server (<a href="http://glassfish.dev.java.net">Project GlassFish</a>).</p>

<p><u>Step-2</u></p>

<p>Use BPEL designer to design a BPEL app. I am not explaining how exactly this needs to be done. Take a look at this <a href="http://java.sun.com/developer/technicalArticles/WebServices/soa3/">article</a> (its a bit too long) or read gopalan for details. </p>

<p>Basically, you need to import the WSDL of the SLSB webservice to the BPEL application and design the BPEL process using the BPEL designer in the netbeans enterprise pack. At the end of everything, the BPEL app will expose a service as shown below in the WSDL snippet.</p>

<p><img alt="bpel-wsdl.png" src="http://weblogs.java.net/blog/binod/example/bpel-wsdl.png" width="747" height="584" /></p>

<p><u>Step-3></u></p>

<p>Create a composite application project, add the BPEL app to the composite application project and deploy it. These are few clicks in the netbeans enterprise pack.</p>

<p><u>Step-4</u><br />
Write the MDB. Import the WSDL of the BPEL application to the MDB as webservice client. The MDB snippet below explains everything.</p>

<p><img alt="mdb-code.png" src="http://weblogs.java.net/blog/binod/example/mdb-code.png" width="666" height="434" /></p>

<p><u>Step-5</u><br />
The last part of the story. Normally, the above JAXWS code in MDB will try to access a service using HTTP transport. Here we want the MDB to access the BPEL app in the same JVM. So, tweak the mdb deployment descriptor to route it to JBI.</p>

<p><img alt="mdb-dd.png" src="http://weblogs.java.net/blog/binod/example/mdb-dd.png" width="984" height="410" /></p>]]>
<![CDATA[<p>Ok, you are still reading. Let's come to the point. <u>How does Java EE Service Engine work?</u></p>

<p>Java EE Service Engine is the glue code that is part of Sun Java System Application Server. One end of the service engine exposes JBI based contracts and is deployed into JBI runtime. The other end interact with appserver's containers, especially the webservices runtime. When the JAXWS client code executes, using a private SPI, it snatches the soap message from the JAXWS client runtime and normalizes and sends it to JBI NMR. Similarly, when the JBI NMR invokes Java EE Service Engine with an incoming JBI request, Java EE Service Engine will pass the soap message to JAXWS server runtime and get the jsr 109 webservice (slsb) invoked. With the new re-architectured JAXWS runtime (<a href="https://wsit.dev.java.net/">Project Tango</a>) we should be able to change all these into a more pluggable architecture.</p>]]>
</content>
</entry>
<entry>
<title>JMS Pluggability and Generic RA for JMS</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2006/05/genericjmsra_he.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-05-26T13:01:59Z</issued>
<id>tag:weblogs.java.net,2006:/blog/binod/273.4906</id>
<created>2006-05-26T13:01:59Z</created>
<summary type="text/plain">JMS pluggability is all about integrating any JMS provider with any Java EE (J2EE) application server. Generic Resource Adapter for JMS enable such an integration.
Here is a progress report about the project.</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>Each J2EE application server comes with their own JMS providers. For a developer, it is a good thing. He can write his jms apps and MDBs easily. But a production environment might be quite different. In many cases, people write a new J2EE application and use it with their existing software stack. That means, a lot of time, you will end up in using one J2EE application server and use a JMS provider that is written by some other vendor.</p>

<p>For most simple applications, it is still okay. Most JMS providers give some sort of JNDI capability so that an application can lookup javax.jms.QueueConnectionFactory and javax.jms.Queue objects and send a message.</p>

<p>The trouble comes, when you need to write a true J2EE application, that use container managed transaction and authentication management, that need to be performant (think of connection pools), need inbound communication with MDBs etc. Then add distributed (XA) transactions to the mix. It gets very complicated.</p>

<p>More than an year after we started http://genericjmsra.dev.java.net project, I did a bit of googling about <a href="http://genericjmsra.dev.java.net">Generic RA for JMS</a>. It seems, many people are able to use different JMS providers with different application servers using this resource adapter.</p>

<p>The resource adapter is now bundled with two application servers. <a href="http://glassfish.dev.java.net">Sun Java System Application server</a> (Project GlassFish) and <a href="http://support.borland.com/servlet/KbServlet/download/4583-102-494/using_jca_to_integrate_jms_with_bas.pdf">Borland Application Server</a>. It is also known to work with <a href="https://genericjmsra.dev.java.net/docs/was-activemq-integration/genericrawithwas.html">Websphere Application Server</a>. These links (<a href="http://comments.gmane.org/gmane.comp.java.geronimo.devel/22741">1</a> and <a href="http://opensource.atlassian.com/confluence/oss/display/GERONIMO/Integrating+A+Third+Party+JMS+Provider">2</a>) indicate that someone has got it working with Geronimo also. Hopefully, more application servers will get into the list sooner or later.</p>

<p>Look like <a href="http://www.theserverside.com/news/thread.tss?thread_id=36669">jencks</a> folks have got it working with their container. Since jenks is very close to Spring, it also can connect to any JMS provider using the resource adapter.</p>

<p>It has also been found working with the many JMS providers. <a href="https://genericjmsra.dev.java.net/docs/websphere-mq-integration-guide/webspheremq_integration_guide.html">WebsphereMQ</a>, <a href="https://genericjmsra.dev.java.net/docs/tibco-genericjmsra-integration-sample-doc/Integrating_Sun_Java_System_Application_Server_with_Tibco_JMS_using_the_Generic_Resource_Adapter_for_JMS.html">Tibco EMS</a>, <a href="http://support.borland.com/servlet/KbServlet/download/4583-102-494/using_jca_to_integrate_jms_with_bas.pdf">OpenJMS</a>, <a href="https://genericjmsra.dev.java.net/docs/was-activemq-integration/genericrawithwas.html">ActiveMQ</a>, <a href="https://genericjmsra.dev.java.net/docs/userguide/userguide.html">Sun Java System Message Queue</a> and <a href="https://genericjmsra.dev.java.net/source/browse/genericjmsra/seebeyondtests/">Seebeyond Message Queue</a> are found to be working with one or more application servers. Hopefully someone will try others (FioranoMQ, SonicMQ, JbossMQ, SwiftMQ etc) also soon.<br />
<a href="http://blogs.sun.com/sivakumart"><br />
Siva</a> recently gave a <a href="http://wiki.java.net/bin/view/Javaone/CommunityCorner">community corner</a> talk titled <em>the availabilty features in the genericjmsra</em> at  JavaOne 2006. Those <a href="https://java-net.dev.java.net/servlets/ProjectDocumentList?folderID=4658&expandFolder=4658&folderID=4658">slides</a> will be useful for folks who want to use the adapter in production. The other good resource is the <a href="https://genericjmsra.dev.java.net/docs/userguide/userguide.html">user guide</a>.</p>]]>

</content>
</entry>
<entry>
<title>http://foss.in event: Project GlassFish demo and slides</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2005/11/httpfossin_even.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-11-30T04:45:09Z</issued>
<id>tag:weblogs.java.net,2005:/blog/binod/273.3711</id>
<created>2005-11-30T04:45:09Z</created>
<summary type="text/plain">In its new form (foss.in) Linux Bangalore, is now open to show all free and open source software. There are many requests at the event to make the project glassfish demo and slides available online.</summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>There is a cool flash demo explaining how to develop a Java EE 5 application using latest <a href="http://www.netbeans.org/">netbeans</a> and <a href="https://glassfish.dev.java.net/public/downloadsindex.html">Project GlassFish</a> builds. Download it here => <a href="http://weblogs.java.net/blog/binod/archive/foss-in-2005-GlassFish-EJB3Persistence-NetBeans-Demo.swf">flash demo</a></p>

<p>Please checkout the <a href="http://weblogs.java.net/blog/binod/archive/GlassFish_FOSS05.pdf">slides</a> of Project GlassFish talk. It contains an overview of Java EE 5 and <a href="https://glassfish.dev.java.net/">Sun Java System Application Server</a> specific features.</p>

<p>If you attend the event, visit Sun stall to see more demos from the glassfish team.</p>]]>

</content>
</entry>
<entry>
<title>Lazy Initialization of Application Server Services.</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/binod/archive/2005/09/lazy_initializa.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-09-02T18:17:56Z</issued>
<id>tag:weblogs.java.net,2005:/blog/binod/273.3195</id>
<created>2005-09-02T18:17:56Z</created>
<summary type="text/plain">This is my first ever blog. I got many e-mails recently, asking me details about a feature called on-demand initialization (or lazy initialization) in Sun Java System Application Server or GlassFish (http://glassfish.dev.java.net) and I thought I could use this blog post to explain what it is all about. </summary>
<author>
<name>binod</name>

<email>Binod.Pg@Sun.COM</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/binod/">
<![CDATA[<p>This is my first ever blog. I am basically a developer/engineer by profession (not a writer). So, please don't expect my blogs to be anywhere near an organized reading material.</p>

<p>Lets come to the topic. </p>

<p>I got many e-mails recently,  asking me details about a feature called on-demand initialization (or lazy initialization) in Sun Java System Application Server or <a href="http://glassfish.dev.java.net">GlassFish</a>  ... and I thought I could use this blog post to explain what it is all about. <br />
<em><br />
What does this feature accomplish?</em><br />
 <br />
After this feature is implemented, the actual startup time for Application Server became nearly half of what it was in its previous version. The memory footprint has also reduced a lot. See Peter's blog about his <a href="http://blogs.sun.com/roller/page/fp?entry=glassfish_milestone_3_observations">experience</a><br />
<em></p>

<p>Why was it taking longer to startup earlier?</em><br />
 <br />
In my mind, Java EE is a mature and really capable technology for enterprise applications. As an Application Server compliant to Java EE, GlassFish supports many technologies or services specified in the Java EE specification. Lets try to name a few of them... Servlet, JSP, Webservices, EJB, JMS, Connectors, JDBC, JMX, JSF.... </p>

<p>Application server, on startup, initialize containers/components that provide these services eagerly and this takes a long time AND lot of memory.</p>

<p><em>So, what does this new feature do?</em><br />
 <br />
Most of the developers are not going to use all the services in the Application Server. I am not talking about those who develop really complex EE applications all the time, but about developers who <a href="https://glassfish.dev.java.net/public/downloadsindex.html">download</a> the Application Server and just try out a few samples, or folks who learn one or two technologies at a time or even folks who work on small projects that use only some of the technologies from the Java EE stack. This group of developers would not like to incur the overhead of startup-time/memory for all the services they would not use.</p>

<p>Hence now, the Sun Java System Application Server does not start all the containers during startup. In fact when you install Application Server and start it afresh, there will be only a handful essential services initialized, namely a local JNDI provider, JMX connector (for administration). <br />
 <br />
<em>Now, how would a developer configure the application server to use the <br />
other services?</em></p>

<p>That is the best part of the feature. User doesn't need to do anything special to initialize the other services that are not started by default. The user uses the application server as he normally would. As and when a service is used, the Application Server will transparently start it.<br />
<u><strong><br />
Here are some details about the implementation.</strong></u><br />
 <br />
Mainly there are 3 "entry points" to the Application Server. The entry points are basic functionality in the Application Server that will be used while accessing a user-facing service in Application Server.</p>

<p>1. JNDI Lookup.</p>

<p>Many services and resources in Application Server are looked up using a JNDI name. Examples? <br />
Looking up an EJB,  a JDBC resource,  a JMS connection factory...<br />
 <br />
2. Server Ports.<br />
 <br />
Whenever you do something with the Application Server, a server port is accessed. It can be when you try to see the index.html of the webserver , or connect to the JMS provider from a standalone application, or it can be when you try to lookup a JDBC resource from server's JNDI provider from a standalone Java application.<br />
 <br />
3. Application Loader.<br />
 <br />
During the loading of an application,the application Server will read the deployment descriptor of the application for house keeping operations and initialization of the application.</p>

<p>Whenever a user-request reach any of these entry points,the Application Server will identify the type of incoming request and start all relevent services (or service groups) that are required. For example, if the user is accessing http port and if webserver is not started, then the webserver is started lazily/transparently. Or if user is accessing JMS port and JMS provider is not started, Application Server will start the JMS provider. When an ear file containing a EJB is loaded, and ORB is not yet started, Application Server will start ORB.</p>

<p>If you are interested in this feature, the code is available for you to see at <a href="http://fisheye.cenqua.com/java.net/viewrep/glassfish/appserv-core/src/java/com/sun/enterprise/server/ondemand">GlassFish FishEye page</a>.</p>

<p>If you like to download the latest MSbuild of glassfish, see the <a href="https://glassfish.dev.java.net/servlets/NewsItemView?newsItemID=2612">link</a> here</p>

<p>For any questions/comments, please use the comments section below or post them at the GlassFish developer's mailing list dev@glassfish.dev.java.net</p>]]>

</content>
</entry>

</feed>