<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bandos&#039; Arcade &#187; Apache</title>
	<atom:link href="http://www.nuwanbando.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nuwanbando.com</link>
	<description>&#34;It&#039;s not about how it is, but how I see it &#34; - Stranger Than Fiction</description>
	<lastBuildDate>Mon, 07 Jun 2010 04:55:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Sharing HTTPS, HTTP sessions in tomcat hosted web-apps</title>
		<link>http://www.nuwanbando.com/2010/05/sharing-https-http-sessions-in-tomcat/</link>
		<comments>http://www.nuwanbando.com/2010/05/sharing-https-http-sessions-in-tomcat/#comments</comments>
		<pubDate>Thu, 06 May 2010 19:33:06 +0000</pubDate>
		<dc:creator>Nuwan Bandara</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Tomcat]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTPS]]></category>

		<guid isPermaLink="false">http://www.nuwanbando.com/?p=440</guid>
		<description><![CDATA[The requirement is to only serve the login page securely and once the user is authenticated (s)he should be redirected to non-secure http mode. I was struggling to do this quite some time back, and just thought of documenting about it. The idea I had was; &#8220;It should be quite simple&#8221;, Facebook does that, Google [...]]]></description>
			<content:encoded><![CDATA[		<div style="float:right;margin:0px 0px 10px 10px;">
			<a class="DiggThisButton DiggMedium" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nuwanbando.com%2F2010%2F05%2Fsharing-https-http-sessions-in-tomcat%2F&title=Sharing+HTTPS%2C+HTTP+sessions+in+tomcat+hosted+web-apps&related=no" ><span style="display:none">The requirement is to only serve the login page securely and once the user is authenticated (s)he should be redirected to non-secure http mode. I was struggling to do this quite some time back, and just thought of documenting about it. The idea I had was; &#8220;It should be quite simple&#8221;, Facebook does that, Google [...]</span></a>		
		</div>		
		<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.nuwanbando.com%2F2010%2F05%2Fsharing-https-http-sessions-in-tomcat%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nuwanbando.com%2F2010%2F05%2Fsharing-https-http-sessions-in-tomcat%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>The requirement is to only serve the login page securely and once the user is authenticated (s)he should be redirected to non-secure http mode. I was struggling to do this quite some time back, and just thought of documenting about it.</p>
<div id="attachment_441" class="wp-caption alignleft" style="width: 366px"><a href="http://www.nuwanbando.com/wp-content/uploads/2010/05/req.jpg"><img class="size-full wp-image-441 " title="req" src="http://www.nuwanbando.com/wp-content/uploads/2010/05/req.jpg" alt="" width="356" height="179" /></a><p class="wp-caption-text">The requirement </p></div>
<p>The idea I had was; &#8220;It should be quite simple&#8221;, Facebook does that, Google does that and why is it still not well documented ?, However the almost all Google search results for my queries were about simply redirecting HTTP traffic to HTTPS for certain URLs, some were using <a href="http://httpd.apache.org/docs/2.0/misc/rewriteguide.html" target="_blank">URL rewriting</a> (mod_rewrite), and some have used server configuration via Tomcat&#8217;s server.xml.</p>
<p>What I really wanted to achieve is to preserve the state between the protocol switch. After some considerable amount of searching I found out this is not achievable (in a very clean manner) with tomcat or rather it is a conflict between security and state management in the servlet spec itself, hence there only exist a <a href="http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg151759.html" target="_blank">dirty hack</a> (not sure if this works) to get it done, but even that hack couldn&#8217;t be applied to my scenario.</p>
<p>So after some thinking I came up with my own hack (I think its even dirtier <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) to solve the issue; Its quite simple, and involves cookie manipulation. My approach was simply read the HTTPS cookie and set it as the HTTP cookie, what I need was one jsp which is served with HTTPS and few lines of Java code.</p>
<div id="attachment_454" class="wp-caption alignleft" style="width: 470px"><a href="http://www.nuwanbando.com/wp-content/uploads/2010/05/sol1.jpg"><img class="size-full wp-image-454" title="sol" src="http://www.nuwanbando.com/wp-content/uploads/2010/05/sol1.jpg" alt="The solution" width="460" height="437" /></a><p class="wp-caption-text">The solution</p></div>
<p>True enough it certainly looks like a hack, but security wise its as same as the Tomcat user group has suggested. so until the new servlet specification answers this question we have to live with this. the code of converting the cookies are as follows.</p>
<div>
<pre class="java" name="code" style="width: 55%;">
    Cookie[] cookies = request.getCookies();
    String sessionId;
    if (cookies != null) {
        for (Cookie c : cookies) {
            if (c.getName().equals("JSESSIONID")) {
                sessionId = c.getValue();
            }
        }
    }

    Cookie k = new Cookie("JSESSIONID", sessionId);
    k.setPath(request.getContextPath());
    response.addCookie(k);
</pre>
</div>
<p>Basically what the code does is, reading the secure cookies while inside the middle.jsp and setting them without security (k.setSecure() is not mentioned hence by default its false), and that&#8217;s about it, once this is done you can simply redirect to the HTTP page.</p>
<div>
<pre class="java" name="code" style="width: 55%;">
response.sendRedirect("http://foo.com:8080/index.jsp");
</pre>
</div>
<p>and now the cookie which originally set via HTTPS is accessible to the HTTP requests, hence the session is shared.</p>
<div id="fb-root"></div>
       <script>
       window.fbAsyncInit = function() {
       FB.init({appId: "108492862525832", status: true, cookie: true,
             xfbml: true});
        };
     (function() {
      var e = document.createElement("script"); e.async = true;
     e.src = document.location.protocol +
       "//connect.facebook.net/en_US/all.js";
     document.getElementById("fb-root").appendChild(e);
   }());
   </script><div class = "fb-div"><fb:like href="http://www.nuwanbando.com/2010/05/sharing-https-http-sessions-in-tomcat/" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" /></div>]]></content:encoded>
			<wfw:commentRss>http://www.nuwanbando.com/2010/05/sharing-https-http-sessions-in-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSO2 Gadget Server 1.1.0, What to expect</title>
		<link>http://www.nuwanbando.com/2010/03/wso2-gadget-server-1-1-0-what-to-expect/</link>
		<comments>http://www.nuwanbando.com/2010/03/wso2-gadget-server-1-1-0-what-to-expect/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 18:38:32 +0000</pubDate>
		<dc:creator>Nuwan Bandara</dc:creator>
				<category><![CDATA[FOSS]]></category>
		<category><![CDATA[WSO2]]></category>
		<category><![CDATA[WSO2 Gadget Server]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Shindig]]></category>
		<category><![CDATA[WSO2 Carbon]]></category>

		<guid isPermaLink="false">http://www.nuwanbando.com/?p=310</guid>
		<description><![CDATA[WSO2 Carbon 3.0.0 &#8211; code name &#8220;Iridium&#8221; is just about to release in few more days. as of WSO2&#8242;s release strategy, all the products will graduate with their next version on top of carbon based platform. As for the newly released Gadget Server it would be version 1.1.0 Features were frozen for version 1.1.0 and [...]]]></description>
			<content:encoded><![CDATA[		<div style="float:right;margin:0px 0px 10px 10px;">
			<a class="DiggThisButton DiggMedium" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nuwanbando.com%2F2010%2F03%2Fwso2-gadget-server-1-1-0-what-to-expect%2F&title=WSO2+Gadget+Server+1.1.0%2C+What+to+expect&related=no" ><span style="display:none">WSO2 Carbon 3.0.0 &#8211; code name &#8220;Iridium&#8221; is just about to release in few more days. as of WSO2&#8242;s release strategy, all the products will graduate with their next version on top of carbon based platform. As for the newly released Gadget Server it would be version 1.1.0 Features were frozen for version 1.1.0 and [...]</span></a>		
		</div>		
		<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.nuwanbando.com%2F2010%2F03%2Fwso2-gadget-server-1-1-0-what-to-expect%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nuwanbando.com%2F2010%2F03%2Fwso2-gadget-server-1-1-0-what-to-expect%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignnone" title="carbon" src="http://wso2.com/wp-content/themes/wso2ng-v2/images/logos/carbon_logo_h42.gif" alt="" width="197" height="42" /> <img class="alignnone" title="GS" src="http://wso2.com/wp-content/themes/wso2ng-v2/images/logos/gs_logo_h42.gif" alt="" width="268" height="42" /></p>
<p><a href="http://wso2.com/products/carbon/" target="_blank">WSO2 Carbon</a> 3.0.0 &#8211; code name &#8220;Iridium&#8221; is just about to release in few more days. as of WSO2&#8242;s release strategy, all the products will graduate with their next version on top of carbon based platform. As for the newly released <a href="http://wso2.org/downloads/gadget-server" target="_blank">Gadget Server</a> it would be version 1.1.0</p>
<p>Features were frozen for version 1.1.0 and that was in the end of February as I recall. We (the GS team) managed to squeeze in few new very important features to this release.</p>
<ul>
<li><strong>Upgraded shindig to the latest version</strong></li>
</ul>
<p>This was a bummer, since WSO2 Carbon platform is running on OSGi, if you had to use a non native OSGi project (i.e. Shindig) you will have to create an OSGi aware <a href="https://svn.wso2.org/repos/wso2/trunk/carbon/orbit/shindig/pom.xml" target="_blank">carbon orbit bundle</a> and make use of it at run time. This was done some time back where shindig was on <em>r734876</em> revision. In-order to leverage new functionalities such as OAuth, Pub-Sub etc. and to patch the bug fixes we thought of updating the shindig carbon orbit bundle. So now shindig is on <em>r910768</em> and is quite up to date.</p>
<ul>
<li><strong>i18n internationalization support for gadgets</strong></li>
</ul>
<p>i18n is not a big deal for Google gadgets since the <a href="http://code.google.com/apis/gadgets/docs/i18n.html" target="_blank">gadget API itself supports it</a>, What we had to do is enable i18n support in shindig. (Which was already implemented by the shindig community)</p>
<ul>
<li><strong>Inter Gadget communication</strong></li>
</ul>
<p>Inter gadget communication, seemed to be the hot topic in our forums and webinars, all most in all tech talks we did about the Gadget Server, some person in the audience raised the question about gadget-to-gadget communication. Our answer was &#8220;it can be done at shindig level, and we are yet to support it&#8221;. So without a long await, with GS v1.1.0 we enabled this feature. The architecture is quite fascinating where there will be zero backend calls and all the communication is done simply on the front-end. Basically each publisher will have a publishing channel and the subscribers can subscribe to this channel. After that its simple pub-sub.</p>
<ul>
<li><strong>The portal will completely run on HTTP transport</strong></li>
</ul>
<p>This was a limitation we had in our fist release. The portal was running only on HTTPS, and the reason behind was that all WSO2 products are running on secure transport and the Gadget Server is also a combination of some specific components which ran on the same platform. For this release we went the extra mile and enabled HTTP for the portal. So once you go to the login page it will switch to the secure transport (HTTPS) and after successful login you will redirect back to the HTTP non-secure mode. (Of cause you can disable HTTP any time and run the portal purely on HTTPS, it all depends on the requirement.)</p>
<p>One disappointment I have is that we couldn&#8217;t integrate OAuth on time. even though it is supported at shindig level we have to do a considerable amount of work from the Gadget Server side to fully support it, hence it is postponed to our next release. You can try the sample <a href="http://dirk.balfanz.googlepages.com/contacts.xml" target="_blank">OAuth GData Gadget</a>, simply adding it by the URL, and that will work like a charm. (nothing useful but just to let you know that we are only few steps behind on it)</p>
<p>Okey so enough sneak peak <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  <a href="http://builder.wso2.org/~carbon/releases/carbon/3.0.0/2PreBeta13/wso2gs-1.1.0.zip" target="_blank">download</a> the Gadget Server pre-beta, play with it, and help us to improve (even in the last minute) by <a href="https://wso2.org/jira/browse/GS">reporting any issues</a>.</p>
<p>Cheers !!</p>
<div id="fb-root"></div>
       <script>
       window.fbAsyncInit = function() {
       FB.init({appId: "108492862525832", status: true, cookie: true,
             xfbml: true});
        };
     (function() {
      var e = document.createElement("script"); e.async = true;
     e.src = document.location.protocol +
       "//connect.facebook.net/en_US/all.js";
     document.getElementById("fb-root").appendChild(e);
   }());
   </script><div class = "fb-div"><fb:like href="http://www.nuwanbando.com/2010/03/wso2-gadget-server-1-1-0-what-to-expect/" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" /></div>]]></content:encoded>
			<wfw:commentRss>http://www.nuwanbando.com/2010/03/wso2-gadget-server-1-1-0-what-to-expect/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache Asia Road Show 2009 &gt;&gt; Keynote speech</title>
		<link>http://www.nuwanbando.com/2009/12/apache-asia-road-show-2009-keynote-speech/</link>
		<comments>http://www.nuwanbando.com/2009/12/apache-asia-road-show-2009-keynote-speech/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 17:29:40 +0000</pubDate>
		<dc:creator>Nuwan Bandara</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Climate change]]></category>

		<guid isPermaLink="false">http://www.nuwanbando.com/?p=238</guid>
		<description><![CDATA[Today I was at Apache Asia road show 2009 at Colombo, and feeling good about myself of attending . It was a great session with many valuable tech talks and more of a valuable community gathering. Am not writing this post to talk about Apache and all the open source movement but about a specific [...]]]></description>
			<content:encoded><![CDATA[		<div style="float:right;margin:0px 0px 10px 10px;">
			<a class="DiggThisButton DiggMedium" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F12%2Fapache-asia-road-show-2009-keynote-speech%2F&title=Apache+Asia+Road+Show+2009+%3E%3E+Keynote+speech&related=no" ><span style="display:none">Today I was at Apache Asia road show 2009 at Colombo, and feeling good about myself of attending . It was a great session with many valuable tech talks and more of a valuable community gathering. Am not writing this post to talk about Apache and all the open source movement but about a specific [...]</span></a>		
		</div>		
		<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F12%2Fapache-asia-road-show-2009-keynote-speech%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F12%2Fapache-asia-road-show-2009-keynote-speech%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Today I was at <a href="http://www.apacheasia09.foss.lk/index" target="_blank">Apache Asia road show 2009</a> at Colombo, and feeling good about myself of attending <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . It was a great session with many valuable tech talks and more of a valuable community gathering. Am not writing this post to talk about Apache and all the open source movement but about a specific talk which made me thinking.</p>
<p>Today, the 1st of 3 days event, the keynote speech was given by a remarkable Sri Lankan Scientist <a href="http://en.wikipedia.org/wiki/Mohan_Munasinghe" target="_blank">Prof Mohan Munasinghe</a> on a topic if I remember correctly, &#8220;<strong>Making Development More Sustainable Will Help Address Climate Change</strong>&#8220;. I know !! It doesn&#8217;t sound much like open source or rather ICT in that matter, but the way he made most of the things related to ICT was quite remarkable. His solution to address bigger problems seems simple. His solution was to address the small problems, change the things what you can change at no cost, exactly quoting &#8220;<strong>Use electricity carefully, eat less meet</strong> <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8221;.</p>
<p>Thinking it through, its the old method in solving the big problem, its just break it in to small problems and try to solve those small ones. The facts Prof Munasinghe talked about climate change was quite terrifying. But however his conclusion was optimistic, he believed as a community that we will stand up against these challenges, be less greedy and help the poor.</p>
<p><img class="aligncenter" title="Climate Change" src="http://yourgreenfriend.com/wp-content/uploads/2009/06/climate_picture.jpg" alt="" width="559" height="274" /></p>
<p>P.S : If anyone of you did find the presentation slides of the keynote speech please do link in comments <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="fb-root"></div>
       <script>
       window.fbAsyncInit = function() {
       FB.init({appId: "108492862525832", status: true, cookie: true,
             xfbml: true});
        };
     (function() {
      var e = document.createElement("script"); e.async = true;
     e.src = document.location.protocol +
       "//connect.facebook.net/en_US/all.js";
     document.getElementById("fb-root").appendChild(e);
   }());
   </script><div class = "fb-div"><fb:like href="http://www.nuwanbando.com/2009/12/apache-asia-road-show-2009-keynote-speech/" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" /></div>]]></content:encoded>
			<wfw:commentRss>http://www.nuwanbando.com/2009/12/apache-asia-road-show-2009-keynote-speech/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>That and This</title>
		<link>http://www.nuwanbando.com/2009/12/that-and-this/</link>
		<comments>http://www.nuwanbando.com/2009/12/that-and-this/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 09:41:11 +0000</pubDate>
		<dc:creator>Nuwan Bandara</dc:creator>
				<category><![CDATA[About Me]]></category>
		<category><![CDATA[FOSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[DiGIT]]></category>
		<category><![CDATA[Shindig]]></category>

		<guid isPermaLink="false">http://www.nuwanbando.com/?p=233</guid>
		<description><![CDATA[Nothing much new to write, was busy with work, WSO2 Gadget Server is about to release in the coming weeks, (I&#8217;ll be writing a whole story about it in a coming post). Apart from all those, my first article was published today in the diGIT magazine, which is a free online IT magazine run by [...]]]></description>
			<content:encoded><![CDATA[		<div style="float:right;margin:0px 0px 10px 10px;">
			<a class="DiggThisButton DiggMedium" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F12%2Fthat-and-this%2F&title=That+and+This&related=no" ><span style="display:none">Nothing much new to write, was busy with work, WSO2 Gadget Server is about to release in the coming weeks, (I&#8217;ll be writing a whole story about it in a coming post). Apart from all those, my first article was published today in the diGIT magazine, which is a free online IT magazine run by [...]</span></a>		
		</div>		
		<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F12%2Fthat-and-this%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F12%2Fthat-and-this%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Nothing much new to write, was busy with work, WSO2 Gadget Server is about to release in the coming weeks, (I&#8217;ll be writing a whole story about it in a coming post). Apart from all those, my first article was published today in the <a href="http://digit.lk/">diGIT</a> magazine, which is a free online IT magazine run by a bunch of Sri Lankans. For some time I wanted to write about SOA and my findings in my final academic year, I thought I will blog about it. But never got a chance or rather, who will read about SOA in my blog <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . For many of such reasons I thought of contributing to diGIT mainly about SOA. With its December issue, my first article about SOA got published. you can check it out at <a href="http://digit.lk/09_dec_soa2" target="_blank">http://digit.lk/09_dec_soa2</a> and leave a comment here <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Other than that, <a href="http://www.apacheasia09.foss.lk/home" target="_blank">The Apache Asia Roadshow 2009</a> is happening in town Dec. 3rd, 4th and 5th. On 4th morning I will be talking about <a href="http://incubator.apache.org/shindig/" target="_blank">Apache Shindig</a> and our experience in WSO2 Gadget Server along with <a href="http://tyrellperera.blogspot.com/" target="_blank">Tyrell</a>. So pay a visit on the event am sure it&#8217;ll be awesome.</p>
<div id="fb-root"></div>
       <script>
       window.fbAsyncInit = function() {
       FB.init({appId: "108492862525832", status: true, cookie: true,
             xfbml: true});
        };
     (function() {
      var e = document.createElement("script"); e.async = true;
     e.src = document.location.protocol +
       "//connect.facebook.net/en_US/all.js";
     document.getElementById("fb-root").appendChild(e);
   }());
   </script><div class = "fb-div"><fb:like href="http://www.nuwanbando.com/2009/12/that-and-this/" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" /></div>]]></content:encoded>
			<wfw:commentRss>http://www.nuwanbando.com/2009/12/that-and-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSF, Spring together with apache CXF</title>
		<link>http://www.nuwanbando.com/2009/01/jsf-spring-together-with-apache-cxf/</link>
		<comments>http://www.nuwanbando.com/2009/01/jsf-spring-together-with-apache-cxf/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 09:43:23 +0000</pubDate>
		<dc:creator>Nuwan Bandara</dc:creator>
				<category><![CDATA[FOSS]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CXF]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.nuwanbando.com/?p=113</guid>
		<description><![CDATA[Good tutorials and resources on Apache CXF How Tos are not easy to digg. I had to spend hours searching and reading to make my small application up and running, Integrating Spring with JSF was pretty straightforward, but when it comes to integrating those two with JSF i got stuck. So this post is about [...]]]></description>
			<content:encoded><![CDATA[		<div style="float:right;margin:0px 0px 10px 10px;">
			<a class="DiggThisButton DiggMedium" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F01%2Fjsf-spring-together-with-apache-cxf%2F&title=JSF%2C+Spring+together+with+apache+CXF&related=no" ><span style="display:none">Good tutorials and resources on Apache CXF How Tos are not easy to digg. I had to spend hours searching and reading to make my small application up and running, Integrating Spring with JSF was pretty straightforward, but when it comes to integrating those two with JSF i got stuck. So this post is about [...]</span></a>		
		</div>		
		<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F01%2Fjsf-spring-together-with-apache-cxf%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nuwanbando.com%2F2009%2F01%2Fjsf-spring-together-with-apache-cxf%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Good tutorials and resources on Apache CXF How Tos are not easy to digg. I had to spend hours searching and reading to make my small application up and running, Integrating Spring with JSF was pretty straightforward, but when it comes to integrating those two with JSF i got stuck.</p>
<p>So this post is about <strong>exposing a web service</strong> as a web project using <strong>JSF front end / Spring backed and CXF</strong> for service invocation</p>
<p>before starting I should mention few valuable resource around the net.</p>
<ul>
<li><a href="http://cwiki.apache.org/CXF20DOC/index.html" target="_blank">The CXF documentation (Hope it will be completed soon)</a></li>
<li><a href="http://wheelersoftware.com/articles/spring-cxf-consuming-web-services.html" target="_blank">Make Web Services Transparent with Spring 2.5 and Apache CXF 2.0 by Willie Wheeler</a></li>
<li><a href="http://www.ibm.com/developerworks/webservices/library/ws-pojo-springcxf/index.html?S_TACT=105AGX04&amp;S_CMP=EDU">Introduction to Web services creation using CXF and Spring by Rajeev Hathi and Naveen Balani</a></li>
<li><a href="http://www.netbeans.org/kb/60/websvc/client.html">Developing JAX-WS Web Service Clients &#8211; netbeans</a></li>
<li><a href="http://weblogs.java.net/blog/caroljmcdonald/archive/2007/09/sample_applicat_3.html" target="_blank">Sample Application using JAX-WS, JSF, Spring, and Java by Carol Mcdonal</a></li>
</ul>
<p>The web service u used was the publicly available spelling checker which is used in the <a href="http://www.netbeans.org/kb/60/websvc/client.html">netbeans tutorial.</a></p>
<p><strong>The Step by step guide as follows &gt;&gt;</strong></p>
<p><strong>Step 1 : </strong></p>
<p>Create the classes from the WSDL you can use netbeans for this task or WSDL2JAVA command (wsdl2java [URL]) in the shell.</p>
<p><span id="more-113"></span></p>
<p><strong>Step2 :</strong></p>
<p>Put the generated classes to your WEB-INF/classes directory and simply write a java class to bind to the JSF front and to expose the web service. I was too lazy to iterate the whole list when showing the incorrect words. so please bare with me <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Example :</p>
<blockquote><p>package demo;</p>
<p>import com.cdyne.ws.CheckSoap;<br />
import com.cdyne.ws.Words;<br />
import java.util.List;</p>
<p>public class SpellChecker {</p>
<p>private CheckSoap service;<br />
private String textArea;<br />
private String wrongWord;</p>
<p>public void setWrongWord(String wrongWord) {<br />
this.wrongWord = wrongWord;<br />
}</p>
<p>public String getWrongWord() {<br />
return wrongWord;<br />
}</p>
<p>public void setTextArea(String textArea) {<br />
this.textArea = textArea;<br />
}</p>
<p>public String getTextArea() {<br />
return textArea;<br />
}</p>
<p>//the spring context sets the service using cxf dynamic proxy</p>
<p><strong>public void setService(CheckSoap service) {<br />
this.service = service;<br />
}</strong></p>
<p>public void checkSpelling() {<br />
try{<br />
System.out.println(&#8220;Checking spelli&#8230;&#8221;);<br />
com.cdyne.ws.DocumentSummary doc = service.checkTextBody(textArea, &#8220;&#8221;);<br />
List allwrongwords = doc.getMisspelledWord();<br />
wrongWord = ((Words) allwrongwords.get(0)).getWord();<br />
}catch (Exception e){<br />
e.printStackTrace();<br />
}</p>
<p>}</p>
<p>}</p></blockquote>
<p><strong>Step 3:</strong></p>
<p>Write a small JSF form to display and for use inputs,</p>
<p>Some thing like,</p>
<blockquote><p>&lt;h:form id=&#8221;spellingForm&#8221;&gt;<br />
&lt;h:outputLabel id=&#8221;label1&#8243; value=&#8221;ENTER you text : &#8221; /&gt;<br />
&lt;br /&gt;<br />
&lt;h:inputTextarea id=&#8221;textarea1&#8243; value=&#8221;#{spellingBean.textArea}&#8221; /&gt;<br />
&lt;br /&gt;<br />
&lt;h:commandButton id=&#8221;cmd1&#8243; value=&#8221;check&#8221; action=&#8221;#{spellingBean.checkSpelling}&#8221; /&gt;<br />
&lt;br /&gt;<br />
&lt;h:outputLabel id=&#8221;lab2&#8243; value=&#8221;The misspelled word is : &#8221; /&gt;<br />
&lt;h:outputText id=&#8221;text2&#8243; value=&#8221;#{spellingBean.wrongWord}&#8221; /&gt;<br />
&lt;/h:form&gt;</p></blockquote>
<p><strong>Step 4:</strong></p>
<p>Here comes the good stuff <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Write a Spring Context file for me it was spellapp-servlet.xml</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;beans xmlns=&#8221;http://www.springframework.org/schema/beans&#8221;<br />
xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;<br />
xmlns:context=&#8221;http://www.springframework.org/schema/context&#8221;<br />
xsi:schemaLocation=&#8221;http://www.springframework.org/schema/beans</p>
<p>http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</p>
<p>http://www.springframework.org/schema/context</p>
<p>http://www.springframework.org/schema/context/spring-context-2.5.xsd&#8221;&gt;</p>
<p><strong>&lt;bean id=&#8221;client&#8221; class=&#8221;com.cdyne.ws.CheckSoap&#8221;<br />
factory-bean=&#8221;clientFactory&#8221; factory-method=&#8221;create&#8221;/&gt;</strong></p>
<p><strong>&lt;bean id=&#8221;clientFactory&#8221; class=&#8221;org.apache.cxf.jaxws.JaxWsProxyFactoryBean&#8221;&gt;<br />
&lt;property name=&#8221;serviceClass&#8221; value=&#8221;com.cdyne.ws.CheckSoap&#8221;/&gt;<br />
&lt;property name=&#8221;address&#8221; value=&#8221;http://ws.cdyne.com/SpellChecker/check.asmx?WSDL&#8221;/&gt;<br />
&lt;/bean&gt;</strong></p>
<p>&lt;/beans&gt;</p></blockquote>
<p><strong>Step 5: </strong></p>
<p>The Faces config (faces-config.xml)</p>
<blockquote><p>&lt;faces-config version=&#8221;1.2&#8243;<br />
xmlns=&#8221;http://java.sun.com/xml/ns/javaee&#8221;<br />
xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;<br />
xsi:schemaLocation=&#8221;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd&#8221;&gt;<br />
&lt;application&gt;<br />
&lt;variable-resolver&gt;org.springframework.web.jsf.DelegatingVariableResolver&lt;/variable-resolver&gt;<br />
&lt;/application&gt;</p>
<p>&lt;managed-bean&gt;<br />
&lt;managed-bean-name&gt;spellingBean&lt;/managed-bean-name&gt;<br />
&lt;managed-bean-class&gt;<br />
demo.SpellChecker<br />
&lt;/managed-bean-class&gt;<br />
&lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;<br />
<strong>&lt;managed-property&gt;<br />
&lt;property-name&gt;service&lt;/property-name&gt;<br />
&lt;value&gt;#{client}&lt;/value&gt;<br />
&lt;/managed-property&gt;</strong></p>
<p>&lt;/managed-bean&gt;</p>
<p>&lt;/faces-config&gt;</p></blockquote>
<p><strong>Step 6:</strong></p>
<p>The web.xml</p>
<blockquote><p>&lt;web-app version=&#8221;2.5&#8243; xmlns=&#8221;http://java.sun.com/xml/ns/javaee&#8221; xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=&#8221;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#8221;&gt;<br />
&lt;!&#8211; Spring Application Context configuration &#8211;&gt;<br />
<strong>&lt;context-param&gt;<br />
&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;<br />
&lt;param-value&gt;</strong><br />
<strong>/WEB-INF/spellapp-servlet.xml<br />
&lt;/param-value&gt;</strong><br />
&lt;/context-param&gt;<br />
&lt;context-param&gt;<br />
&lt;param-name&gt;javax.faces.CONFIG_FILES&lt;/param-name&gt;<br />
&lt;param-value&gt;/WEB-INF/faces-config.xml&lt;/param-value&gt;<br />
&lt;/context-param&gt;</p>
<p>&lt;context-param&gt;<br />
&lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;<br />
&lt;param-value&gt;server&lt;/param-value&gt;<br />
&lt;/context-param&gt;<br />
&lt;listener&gt;<br />
<strong>&lt;listener-class&gt;<br />
org.springframework.web.context.request.RequestContextListener<br />
&lt;/listener-class&gt;</strong><br />
&lt;/listener&gt;<br />
&lt;context-param&gt;<br />
&lt;param-name&gt;com.sun.faces.verifyObjects&lt;/param-name&gt;<br />
&lt;param-value&gt;false&lt;/param-value&gt;<br />
&lt;/context-param&gt;<br />
&lt;context-param&gt;<br />
&lt;param-name&gt;com.sun.faces.validateXml&lt;/param-name&gt;<br />
&lt;param-value&gt;true&lt;/param-value&gt;<br />
&lt;/context-param&gt;<br />
<strong>&lt;listener&gt;<br />
&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;<br />
&lt;/listener&gt;</strong><br />
&lt;servlet&gt;<br />
&lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;<br />
&lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;<br />
&lt;load-on-startup&gt;3&lt;/load-on-startup&gt;<br />
&lt;/servlet&gt;<br />
&lt;servlet&gt;<br />
&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;<br />
&lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;<br />
&lt;load-on-startup&gt;2&lt;/load-on-startup&gt;<br />
&lt;/servlet&gt;<br />
&lt;servlet-mapping&gt;<br />
&lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;<br />
&lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;<br />
&lt;/servlet-mapping&gt;<br />
&lt;servlet-mapping&gt;<br />
&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;<br />
&lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;<br />
&lt;/servlet-mapping&gt;<br />
&lt;session-config&gt;<br />
&lt;session-timeout&gt;<br />
30<br />
&lt;/session-timeout&gt;<br />
&lt;/session-config&gt;<br />
&lt;welcome-file-list&gt;<br />
&lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt;<br />
&lt;/welcome-file-list&gt;<br />
&lt;/web-app&gt;<br />
<strong><br />
</strong></p></blockquote>
<p><strong>Step 7:</strong></p>
<p>That&#8217;s It Build it deploy it. Have fun <img src='http://www.nuwanbando.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <strong><br />
</strong></p>
<div id="fb-root"></div>
       <script>
       window.fbAsyncInit = function() {
       FB.init({appId: "108492862525832", status: true, cookie: true,
             xfbml: true});
        };
     (function() {
      var e = document.createElement("script"); e.async = true;
     e.src = document.location.protocol +
       "//connect.facebook.net/en_US/all.js";
     document.getElementById("fb-root").appendChild(e);
   }());
   </script><div class = "fb-div"><fb:like href="http://www.nuwanbando.com/2009/01/jsf-spring-together-with-apache-cxf/" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" /></div>]]></content:encoded>
			<wfw:commentRss>http://www.nuwanbando.com/2009/01/jsf-spring-together-with-apache-cxf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
