tag:blogger.com,1999:blog-81956200123194826472024-03-13T13:41:28.876-07:00Sensible RationalizationAn effort to rationalize events happening around us - mostly software engineering !!Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.comBlogger51125tag:blogger.com,1999:blog-8195620012319482647.post-46315086528231109622013-03-19T10:02:00.001-07:002013-03-19T12:25:33.399-07:00Integrating JBoss Admin iOS App with Apigee App Perf Monitoring Tool<div dir="ltr" style="text-align: left;" trbidi="on">
Ever since I left JBoss/Red Hat last year to work on <a href="http://instaops.com/" target="_blank">InstaOps</a>, a start up that I co-founded, I have always wanted to stay connected not only with many life long friends that I have made at Red Hat but also with amazing technologies that are built over there. Along this line, I came across <a href="https://github.com/cvasilak/JBoss-Admin" target="_blank">JBoss Admin iOS mobile app</a> and wondered what if I could integrate this app with iOS SDK that we have built. The app is very well designed thanks to <a href="https://twitter.com/cvasilak" target="_blank">Christos (@cvasilak)</a> and uses standard iOS frameworks so <a href="http://apigee.com/docs/enterprise/content/add-monitoring-your-ios-application" target="_blank">integration</a> literally took less than 10 minutes. If I were a brand new user, <a href="http://apigee.com/docs/enterprise/content/add-monitoring-your-ios-application" target="_blank">the end to end integration</a> would have probably taken 20 min most of which would have been time taken to sign up and download the SDK. ;-). Here is a screenshot of app running on Simulator:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ymiaKa8kFzw/UUi7fzx6QeI/AAAAAAAAJOw/Qji5cx4kFJc/s1600/Screen+Shot+2013-03-19+at+2.21.29+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-ymiaKa8kFzw/UUi7fzx6QeI/AAAAAAAAJOw/Qji5cx4kFJc/s320/Screen+Shot+2013-03-19+at+2.21.29+PM.png" width="152" /></a></div>
<br />
<br />
You can see the code changes that I had to make to integrate our SDK on <a href="https://github.com/prabhatjha/JBoss-Admin/commit/7747e79eb2e02170d57805af00c7dad8284ea5af" target="_blank">GitHub</a>. Changes are very minimal and in terms of new lines of code, it's literally 2 files (App Delegate header and impl) and less than 5 lines of code. Once I ran the app on Simulator, following are screenshots of what I could see in our dashboard:<br />
<br />
<br />
<h3>
<ul style="text-align: left;">
<li>Automagic Log Capture</li>
</ul>
</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-u_sKxcA3tz8/UUiXjPFpXNI/AAAAAAAAJOY/24rYR2eh9Z0/s1600/Screen+Shot+2013-03-18+at+12.21.10+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="232" src="http://4.bp.blogspot.com/-u_sKxcA3tz8/UUiXjPFpXNI/AAAAAAAAJOY/24rYR2eh9Z0/s640/Screen+Shot+2013-03-18+at+12.21.10+PM.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<h3>
<ul style="text-align: left;">
<li>Automagic Network Capture</li>
</ul>
</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-fP31SJ7e1Hs/UUiX15fCvrI/AAAAAAAAJOg/QkicNLA9qhQ/s1600/Screen+Shot+2013-03-18+at+12.21.36+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="441" src="http://4.bp.blogspot.com/-fP31SJ7e1Hs/UUiX15fCvrI/AAAAAAAAJOg/QkicNLA9qhQ/s640/Screen+Shot+2013-03-18+at+12.21.36+PM.png" width="640" /></a></div>
<div>
<br /></div>
<br />
<div>
<br /></div>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
The one network error you see on the chart is because I had not started AS7 before I started the app. </div>
<div>
<br /></div>
<div>
If you like what you see and are into mobile App development, <a href="http://apigee.com/docs/enterprise/content/analyze_apps" target="_blank">pls give it a shot</a>. <b>It's free.</b> Let me know your feedback (@prabhatjha). We currently have SDK for native <a href="http://apigee.com/docs/enterprise/content/add-monitoring-your-android-application" target="_blank">Android</a> and <a href="http://apigee.com/docs/enterprise/content/add-monitoring-your-ios-application" target="_blank">iOS apps</a>.</div>
<div>
<br /></div>
</div>
<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-90088271659236313432013-02-02T10:35:00.000-08:002013-02-02T10:35:45.261-08:00Components of Mobile App Performance AnalyticsJust wanted to drop a line that I blogged about three critical components of real time mobile app performance analytics solution at Apigee Blog. <a href="http://blog.apigee.com/detail/analytics_platforms_data_capture_data_processing_data_visualization">http://blog.apigee.com/detail/analytics_platforms_data_capture_data_processing_data_visualization</a><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-56652247327405785112012-06-18T21:55:00.000-07:002012-06-18T21:55:27.889-07:00Infinispan and Twilio integration<div dir="ltr" style="text-align: left;" trbidi="on">
You have a good old JavaEE transactional application where you have done all right things such as database index, caching etc so that its performance is good. If you are really careful and want to make sure that it keeps performing well and scaling well as well, you would use <a href="http://jboss.org/infinispan">Infinispan</a> [1]. ;-) For some extraordinary reasons, imagine that when an entry gets added to the cache, you want to get notified right away. I will show you in this blog how you can integrate <a href="https://www.twilio.com/">Twilio</a> with cache events in Infinispan so that you get an SMS when a cache entry is created.<br />
<br />
<br />
<ul style="text-align: left;">
<li>You need to create a cache event listener which is simply annotating a POJO with listener annotation and annotating relevant methods for event you are interested in.<pre>@Listener
public class InfinispanTwilioCacheListener
...
@CacheEntryCreated
public void print(CacheEntryCreatedEvent event) {
..
}
</pre>
</li>
<li>Register this listener to your cache, not at cache manger. See <a href="http://community.jboss.org/docs/DOC-14871">Listeners and Notfications</a> for details.
<pre>defaultCacheManager().getCache(CACHE_NAME).addListener(new InfinispanTwilioCacheListener());
</pre>
</li>
<li>Create a utility method to get SmsFactory from Twilio Rest Client.
<pre>private SmsFactory getTwilioSmsFactory () {
if (client == null)
client = new TwilioRestClient("YOUR_TWILIO_SID", "YOUR_TWILIO_TOKEN");
Account mainAccount = client.getAccount();
SmsFactory smsFactory = mainAccount.getSmsFactory();
return smsFactory;
</pre>
</li>
<li>Send an SMS. You would add this in your method annotated with @CacheEntryCreated<pre> Map<string, string=""> smsParams = new HashMap<string, string="">();
smsParams.put("To", "VALID_PHONE_NUMBER");
smsParams.put("From", "TWILIO_PHONE_NUMBER");
smsParams.put("Body", "A cache entry got created" + event.getKey().toString());
try {
this.getTwilioSmsFactory().create(smsParams);
} catch (TwilioRestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}</string,></string,></pre>
</li>
</ul>
Here is a screenshot of my phone when an SMS was sent.
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-hLZAvvYkX-8/T-AEMlzAmpI/AAAAAAAAAEU/lsCfLNvHbPM/s1600/twilio.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-hLZAvvYkX-8/T-AEMlzAmpI/AAAAAAAAAEU/lsCfLNvHbPM/s320/twilio.JPG" width="240" /></a></div>
Note, if you are using a trial account then you can not call or send an SMS without verification of that number which obviously makes sense. If the number is not verified then you will get an exception like : "<span style="background-color: white;">com.twilio.sdk.TwilioRestException: The number XXXXX is unverified. Trial accounts cannot send messages to unverified numbers; verify XXXXX at twilio.com/user/account/phone-numbers/verified, or purchase a Twilio number to send messages to unverified numbers"</span><br />
<span style="background-color: white;"><br /></span><br />
<span style="background-color: white;">You can find the complete code at </span><a href="https://github.com/prabhatjha/infinispan-examples">https://github.com/prabhatjha/infinispan-examples</a> which is forked from <a href="https://github.com/mgencur/infinispan-examples">https://github.com/mgencur/infinispan-examples</a> .<br />
<span style="background-color: white;"><br /></span><br />
<span style="background-color: white;">[1] I work with Infinispan and <a href="http://sensiblerationalization.blogspot.com/2012/04/what-does-it-mean-to-be-jboss-data-grid.html">JBoss Data Grid</a> </span><br />
<div>
<span style="background-color: white;"><br /></span></div>
</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-70535402032526016962012-04-23T08:15:00.000-07:002012-04-23T08:15:25.247-07:00What does it mean to be JBoss Data Grid ??<div dir="ltr" style="text-align: left;" trbidi="on">
Red Hat recently announced beta release of <a href="http://www.redhat.com/promo/dg6beta/" target="_blank">JBoss Data Grid</a> (JDG) , a supported product based on <a href="http://www.jboss.org/infinispan/" target="_blank">Infinispan</a>. <a href="http://www.jboss.org/infinispan/" target="_blank">Infinispan</a> was first announced in 2009 and its first GA release was made in February, 2010. So it took more than three years for us, folks at JBoss, to announce a supported beta release. In case you are wondering why it took so long, here are few things to consider. Besides introducing several handy features such as virtual nodes, grouping API, deadlock detection and optimization, improvements with transactions, we wanted to make sure that it<br />
<div style="text-align: left;">
</div>
<ul style="text-align: left;">
<li>can scale in a large cluster. Scalability is a very generic term and its meaning is highly contextual. For JDG, we narrowed down it to two : client scalability and data scalability.</li>
<ul>
<li>Client Scalabilty: Given a percentage of data in virtual heap, does JDG handle more client requests as more nodes are added to the cluster? We measure throughput, 99 percentile response time under read heavy, write heavy scenarios to verify this assertion.</li>
<li>Data Scalability: Given a fix number of clients, how much data can be filled in virtual heap while performance metrics such as throughput and 99 percentile response time are still under user defined values. This is again tested under read heavy, write heavy scenarios. </li>
</ul>
<li>is elastic. Does the cluster scale out and scale in? As nodes are added and removed, how long does it take for cluster to stabilize? This stability is measured by comparing data distribution before and after nodes leave and join.</li>
<li>is resilient. While cluster is in active use and node/s crash, what's the impact on throughput, response time? Is there any data inconsistency? How long does it take to stabilize?</li>
<li>is stable. Tests are run for long time and monitored for CPU, memory usage, number of full GC, average GC time.</li>
</ul>
<div>
This matrix gets quite complicated if you add various configurations that are available in JDG such as three different end points (Hot Rod, memcached, REST), partially versus fully replicated modes aslo known as "DISTRIBUTED" and "REPLICATED" mode respectively, synchronous vs asynchronous replication, number of virtual nodes, READ heavy vs WRITE heavy, L1 cache enabled vs disabled, File Cache Store, JDBC cache store, and so on. </div>
<div>
<br /></div>
<div>
I have only touched the performance and scalability aspects in details. There are various other functional verification which gets quite complicated as well if you think in terms of OS+JVM+File System + DB combinations we have to certify. </div>
<div>
<br /></div>
<div>
I can proudly said that we have come a long way and come GA availability, our customers will have in their hands an extremely scalable and highly available data grid platform. And I should mention linear scalability as well!! Wait should not be too long. ;-)</div>
</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-13400529640253573902011-12-07T09:20:00.000-08:002011-12-07T09:47:39.581-08:00Things I installed after fresh Fedora 16 installationGnome Tweak Tool<br />Gnome Shell Extensions<br /><ul><li>gnome-shell-extension-common-3.2.0-2.fc16.noarch</li><li>gnome-shell-extension-apps-menu-3.2.0-2.fc16.noarch</li><li>gnome-shell-extension-icon-manager-0-0.4.gitc34779c.fc16.noarch</li></ul>Tint2<br />gconf-editor<br />dconf-editor<br />Google Chrome , Flash plugin, Talk plugin<br />Adobe Reader<br />Libre Office<br />Different JDKs<br />Thunderbird and lightning<br />icedtea-web for java webstart<br />MySQL and Administrator<br />Eclipse EE, m2eclipse and its extras<br />Maven<br />Skype<br />wget<br />subversion<br />git<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-42702280625681935062011-11-08T19:50:00.000-08:002011-11-08T19:50:50.131-08:00One of a kind immigration and visa story !!<div dir="ltr" style="text-align: left;" trbidi="on">The saga started way back in 2009 and I paid off the price of minor lapse in 2011. Now that I have your attention, here is the details.<br />
<br />
My mom, a Nepali citizen, came to visit us in Texas for a period of six months in 2009. Six months is the most you can stay in USA if you are on a tourist visa without applying for extension. We knew this rule and certainly wanted to follow it. A glitch came when the person who was supposed to go back with her had to cancel his plan. I prefer to have somebody accompany my mom who speaks English so I started looking for a person who could match her itinerary. Probabilistically, chances of finding a person who you know and has the same itinerary is very low and that's what happened. We could not find one who was traveling along the route within the six month limit but we did have a person flying back to Nepal after one week of that period. So I changed the itinerary and at the same time filed an application for extension of six months stay hoping that there should not be a problem of extending the say since we were only asking for couple of extra weeks in the worst case.<br />
<br />
As you might have guessed, the extension was denied. Now what? Re-booking the ticket was going to cost me couple of hundred of dollars so I thought it may not be too "risky" to overstay for a week and that's what we decided. There was no problem going back to Nepal so it turned out to be a well calculated risk.<br />
<br />
Come 2011, my mom came back again to attend my sister's graduation. At Boston airport, officials wont let her pass the immigration because her visa had expired. She had got a 5-year multiple entry visa starting 2009 so visa was valid at least 2014. It turns out that if you overstay, your visa is automatically canceled and you will be sent back to your country if you manage to land in US. Obviously we did not know that, did you? Thankfully immigration officials understood that it was not done on purpose and they let my mom in for a period of six months with constraints that we would not be able to apply for extension and she would have to leave USA before six month period. That's totally fair and we all appreciated the generosity of officials. The six month period is still valid as of this writing and will be over on Nov 10.<br />
<br />
Today is Nov 8 and also when my mom has her flight back to Nepal through London. My mom was not allowed to board the flight at Boston airport. Before you read further, I would like you to think why that could be the case. It defies logic and I don't know how general folks like me is supposed to know these things!!<br />
<br />
There is no problem leaving USA but there is a problem with transit at London airport. It turns out that if your USA visa has expired/canceled then you can not transit at London airport without having a visa. If we had known that we obviously would have applied for a transit visa but it was too late again. Did you know that? :-( This only happens at London airport, not at other airports. On top of that I have only 2 days to sort this mess out.<br />
<br />
After debating many options, I decided to get a new one way ticket that did not include a transit at London and let go off previous return ticket. I not only lost good chunk of money on return ticket but new one way ticket for NY-Dubai-KTM cost me almost a thousand dollar. My sister drives my mom to NY tomorrow and she departs from NY on 10th morning. I hope that even after this, she gets back home on time and without much hassle. I will keep my fingers crossed and will definitely think twice about flying through London.<br />
<br />
BTW, what's so special about London that they have special rule that no other airport has about transit?</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com3tag:blogger.com,1999:blog-8195620012319482647.post-90431851570128414422011-08-25T13:00:00.000-07:002011-08-25T13:11:59.737-07:00Java EE6, JBoss AS7 and OpenShift talk at Austin JUGFor August 2011 Austin JUG meeting, Red Hat is sponsoring a talk on Java EE6, <a href="http://www.jboss.org/as7">JBoss AS 7</a> and <a href="https://openshift.redhat.com/app/">OpenShift</a>. I will be covering JBoss AS7 and EE6 while my colleague David Blado will do a presentation and demo using OpenShift, Red Hat's PAAS offering. I hope to see you Austinites and their neighbors at the meeting. JBoss AS7 landing page talks about 7 reasons to love it but I will give you a very compelling 8th reason and probably more. ;-) In case this all is not appealing enough, there are free pizza and drinks as well. More details at <a href="http://austinjug.org/index.jsp?p=events-20110830">http://austinjug.org/index.jsp?p=events-20110830</a><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-11176500112647971772011-05-16T11:45:00.000-07:002011-05-17T05:50:06.999-07:00My small contribution to RESTEasy projectI am working on some example to play with <a href="http://www.jboss.org/infinispan/">Infinispan</a> and in this example, I wanted to store a YAML blob in the cache and play with Infinispan's different cache configuration options. To consume a YAML blob, I developed a REST interface using <a href="http://www.jboss.org/resteasy">RESTEasy</a>. RESTEasy's YAML provider worked pretty well but for the case when blob did not comply with YAML syntax. As expected, it would throw error but error message was far from helpful:<br /><br /><code><br />Caused by: java.lang.NullPointerException<br />at org.ho.yaml.JYamlParserEvent.getBean(Unknown Source)<br />at org.ho.yaml.YamlDecoder.readObject(Unknown Source)<br />at org.ho.yaml.YamlConfig.load(Unknown Source)<br />at org.ho.yaml.YamlConfig.load(Unknown Source)<br />at org.ho.yaml.Yaml.load(Unknown Source)<br /></code><br />As of 2.0.1 RESTEasy version, YAML support was provided using <a href="http://jyaml.sourceforge.net/">JYAML</a> which is not under development anymore. So I gave a shot at integrating <a href="http://www.snakeyaml.org">SnakeYaml </a>which is a very active project with good community around it. It was not a whole lot of work and it did not cause any regression in my local testing so I went ahead and committed to trunk after discussing with <a href="http://bill.burkecentral.com/">Bill</a>. Thanks Bill. More details are at <a href="https://issues.jboss.org/browse/RESTEASY-543">https://issues.jboss.org/browse/RESTEASY-543</a> . I updated the RESTEasy's doc as well..isn't that nice? ;-)<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-62264807687657034112011-05-10T21:22:00.001-07:002011-05-10T21:35:49.466-07:00Tips when using curl to do an HTTP POST !I have been playing with <a href="http://www.jboss.org/resteasy">RestEasy</a> stuff a bit lately and to test my RESTful webservices, I was using curl to do a HTTP GET and POST. To add to the fun, I wanted to use a YAML file as POST payload. I will talk about YAML and RestEasy in a separate blog post, but when you do a POST as<br /><br /><code><br />curl -X POST -d @/home/prabhat/house.yaml -H "Content-type: text/x-yaml" http://localhost:8080/eejot-rest/rest/houses<br /></code><br /><br />curl strips all newline which is what a browser does. YAML depends on new line and white spaces so that would result into all sort of deserialization issues on server side. The correct way to do instead is<br /><br /><code><br />curl -X POST --data-binary @/home/prabhat/payload.yaml -H "Content-type: text/x-yaml" http://localhost:8080/eejot-rest/rest/houses<br /></code><br />Curl man page is very clear on this but sometimes we tend to have false assumption. RTFM Prabhat!<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-82847217544502139142011-05-03T06:30:00.000-07:002011-05-03T06:47:44.455-07:00How to delete a svn repo and recover itI woke up this morning and before I had my coffee, I did something like following:<br /><br />svn delete .<br />svn commit -m "some clean up"<br /><br />As I said I did this before I had my coffee. ;-) But why would I do such thing? SVN showed M for . because I was playing with some svnignore stuff. The above command completely wiped out the branch I was working on. When I realized what I did, I did not need coffee anymore.<br /><br />After little googling, I did following<br /><br />svn cp -m "restore.." https://eejot.org/branches/my-branch@110 https://eejot.org/branches/my-branch<br /><br />where 110 is x-1 with x being the revision number which nuked the branch I was working on.<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-5304957320242666072011-04-17T19:02:00.000-07:002011-04-17T19:27:24.981-07:00Winning changes everything !!India won 2011 World Cup Cricket and I am really really happy for Indian team specially Sachin Tendulkar. I am from Nepal but I grew up following Indian cricket since cricket was not very popular in Nepal back then and Nepali team is not good enough yet to qualify for the world cup. <br /><br />I would like to think that I played a part in India's victory. Whenever I watched a crucial match, India lost most of the time. It used to hurt a lot; 1996 semi final against Sri Lanka, 2003 world cup final against Australia and 2007 world cup in West Indies come to my mind. So I made a decision this time that I would not watch any live match involving India. This was obviously very difficult but I really wanted Sachin to have his hands on the trophy like millions of Indian people as well as many non Indian avid cricket fans. I am no longer going to do this stupid thing anymore and will just try to enjoy the game. Here is wishing Nepali cricket team to shine so that I have my own country to root for.<br /><br />When India was loosing many crucial matches and some regular matches abroad, several pundits would sing in chorus on bad infrastructures in India, Indian team lacking self belief, Australian team being mentally tougher, Australian team having good bench strength etc etc. I do believe some of them to be partly correct but I never agreed that they were to the extreme these pundits thought they were. Now that India has won, same pundits are singing the chorus other way around. <br /><br />I believe teams go through cycle. Some naturally gifted players emerge and they form the core of a team which help them win more matches than they would have otherwise. Of course having good infrastructures and bench strength help but they don't disappear all of sudden when you loose. Australia loosing its dominance has more to do with its core team members (Waugh, Warne, McGrath) retiring in quick succession which is analogous to what happened to West Indies team and which is likely going to be the case for Indian team (primarily in Test cricket) when Tendulkar, Dravid, Laxman retire.<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/18220849795910855444noreply@blogger.com2tag:blogger.com,1999:blog-8195620012319482647.post-46378326545429863092011-03-28T06:30:00.000-07:002011-03-28T06:30:58.053-07:00Richfaces showcase on Cloudbees<div dir="ltr" style="text-align: left;" trbidi="on">To continue with my experiments with different PAAS providers, I took Run@Cloud provided by <a href="http://www.cloudbees.com/">Cloudbees</a> for a ride this time. Overall its web interface is very straightforward and intuitive and similar to what I mentioned about <a href="http://sensiblerationalization.blogspot.com/2011/03/richfaces-showcase-on-amazons-elastic.html">AWS Elastic Beanstalk</a> . I was able to deploy Richfaces 4 Showcase application in couple of minutes and you can see in action at <a href="http://showcase.eejot.cloudbees.net/">http://showcase.eejot.cloudbees.net</a>. Once your app is running, besides application logs, you can monitor different operational parameters such as system load, number of request, session etc as evident in following screen shot:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-lgn7Q_fky9A/TY_rjn_7_6I/AAAAAAAAAEM/TgStk7D3sGU/s1600/bees-ops.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="http://4.bp.blogspot.com/-lgn7Q_fky9A/TY_rjn_7_6I/AAAAAAAAAEM/TgStk7D3sGU/s320/bees-ops.png" width="320" /></a></div><br />
<br />
Keep in mind that I did not try its SDK which allows you to deploy your webapp from command line on your local box.<br />
<br />
I found it a bit odd that when you add a new application, the wizard asks you for app name only and not the actual deployable. The advantage of this approach is that you get a running URL immediately to which you can upload your .war. I would have merged these two steps into one. <br />
<br />
I also would have liked to have a shell access to actual server as well as ability to specify different JVM parameters. May be it's a work in progress? ;-)<br />
<br />
<br />
</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-9970366361201978612011-03-20T22:06:00.000-07:002011-03-20T22:10:06.287-07:00Richfaces showcase on Amazon's Elastic Beanstalk<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://jboss.org/richfaces">Richfaces 4</a> is around the corner and it runs pretty much same in both Tomcat and JBoss. The major difference is that with Tomcat, you have to bundle in your .war a JSF implementation which could be Mojarra or MyFaces. I don't have a preference on JSF implementation at this stage. Given that Richfaces runs without problem on Tomcat, I thought I should take <a href="http://aws.amazon.com/elasticbeanstalk/">AWS Elastic Beanstalk</a> for a ride. As it turns out deploying is as simple as deploying it to your local tomcat instance which is a good thing but it also differs a bit.<br />
<br />
In following screen shot, you can see that I have chosen Richfaces showcase application (showcase.war) which I want to deploy on a 32-bit Linux OS running Tomcat 6. Once app is deployed, it should be deployed on <a href="http://prabhat.elasticbeanstalk.com/">http://prabhat.elasticbeanstalk.com</a> (I have shut down my instance so link wont work).<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://lh3.googleusercontent.com/-wfIihrESqCc/TYbbM_KNQDI/AAAAAAAAAD8/fQtOOz5SbPA/s1600/beanstalk-new.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://lh3.googleusercontent.com/-wfIihrESqCc/TYbbM_KNQDI/AAAAAAAAAD8/fQtOOz5SbPA/s320/beanstalk-new.png" width="320" /></a></div><br />
<br />
When I deployed my app, I expected my app to be available at <a href="http://prabhat.elasticbeanstalk.com/">http://prabhat.elasticbeanstalk.com/showcase</a> in line with what I get when I deploy the app locally which is <a href="http://localhost:8080/showcase">http://localhost:8080/showcase</a> . But Beanstalk renames the .war and deploys it as /usr/share/tomcat6/webapps/ROOT which is why it's available under root context . This is important to know because in the next step of configuration, you would need to supply the URL which can be used for health check. I initially provided /showcase and I ran into problem. Following is what should be:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://lh4.googleusercontent.com/-1I_GJJ-oI9s/TYbbSw7SwuI/AAAAAAAAAEA/s35F2FUuhCU/s1600/beanstalk-healthcheck.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://lh4.googleusercontent.com/-1I_GJJ-oI9s/TYbbSw7SwuI/AAAAAAAAAEA/s35F2FUuhCU/s320/beanstalk-healthcheck.png" width="320" /></a></div><br />
<br />
<br />
Other noteworthy differences or rather limitations are that currently Beanstalk configuration does not give you options to edit JVM parameters initially. Once you have instance up and running, it does give you an option to edit JVM configurations as well pass five application specific parameters but the name of parameters has to be PARAM1, PARAM2 ... May be this will be fixed in future versions or it's already available and I don't know. The latter is likely given that I did not spend a whole lot of time on it. Anyway, here is screen shot of app running on Beanstalk.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://lh4.googleusercontent.com/-J--qbKAugHM/TYbdotV3cFI/AAAAAAAAAEI/1l6w44tqUis/s1600/showcase-beanstalk.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="190" src="https://lh4.googleusercontent.com/-J--qbKAugHM/TYbdotV3cFI/AAAAAAAAAEI/1l6w44tqUis/s320/showcase-beanstalk.png" width="320" /></a></div><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://lh4.googleusercontent.com/-KtOuk0L7fIA/TYbbZmrT99I/AAAAAAAAAEE/MIPZDZ5XiQg/s1600/beanstalk.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a></div><br />
<br />
<br />
<br />
<br />
</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com2tag:blogger.com,1999:blog-8195620012319482647.post-29221775776829646832011-03-08T19:14:00.000-08:002011-03-08T19:14:03.592-08:00Quick tip on hibernate batch operation<div dir="ltr" style="text-align: left;" trbidi="on">You can find the details of what batch operation with respect to DB is and related Hibernate guide at <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html">http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html</a> . Any time you need to do bulk inserts/updates, it's better to do in batch to get a better performance. Recently I was developing a small app and followed Hibernate guide to make sure that my configurations were correct. Even after trying several things, I kept seeing following in log generated by Hibernate:<br />
<code><br />
Hibernate: insert into Member (name, id) values (?, ?)<br />
Hibernate: insert into Member (name, id) values (?, ?)<br />
Hibernate: insert into Member (name, id) values (?, ?)<br />
Hibernate: insert into Member (name, id) values (?, ?)<br />
Hibernate: insert into Member (name, id) values (?, ?) </code><br />
<br />
But batch operation is supposed to generate statements like<br />
<br />
<code><br />
insert into Member (name, id) values ('name0', 1),('name1', 2),('name2', 3),('name3', 4),('name4', 5),('name5', 6),('name6', 7),('name7', 8),('name8', 9),('name9', 10),('name10', 11),('name11', 12),('name12', 13),('name13', 14),('name14', <br />
15),('name15', 16),('name16', 17),('name17', 18),('name18', 19),('name19', 20) </code><br />
<br />
It turns out that even when batch operation is in progress, hibernate log shows individual operation. If you don't know this, you might be up for a ride figuring out what the heck is going on. The best way to make sure is to turn on the query logs in DB itself. For MySQL5 installed on Fedora, you do it by adding log parameter at /etc/my.conf<br />
<code><br />
[mysqld]<br />
datadir=/var/lib/mysql<br />
socket=/var/lib/mysql/mysql.sock<br />
user=mysql<br />
log=/var/log/mysqld.log<br />
</code><br />
<br />
You should see statements like following at /var/log/mysqld.log :<br />
<br />
<code>2 Query insert into Member (name, id) values ('name0', 1),('name1', 2),('name2', 3),('name3', 4),('name4', 5),('name5', 6),('name6', 7),('name7', 8),('name8', 9),('name9', 10),('name10', 11),('name11', 12),('name12', 13),('name13', 14),('name14', <br />
15),('name15', 16),('name16', 17),('name17', 18),('name18', 19),('name19', 20)<br />
2 Query commit </code><br />
<br />
The complete test project is at <a href="http://anonsvn.jboss.org/repos/qa/prabhat/batch-insert">http://anonsvn.jboss.org/repos/qa/prabhat/batch-insert</a> . The relevant hibernate configuration is at <a href="http://anonsvn.jboss.org/repos/qa/prabhat/batch-insert/src/main/resources/hibernate.cfg.xml">http://anonsvn.jboss.org/repos/qa/prabhat/batch-insert/src/main/resources/hibernate.cfg.xml</a> . If you are letting hibernate generate the primary key then don't use GenerationType.Identity in your model otherwise batch insert will not take place.</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com12tag:blogger.com,1999:blog-8195620012319482647.post-74221735315221254852011-03-02T10:14:00.000-08:002011-03-02T10:14:40.383-08:00New guide, tips and tricks for GateIn<div dir="ltr" style="text-align: left;" trbidi="on">Recently my team members published several how-to docs and guides on customizing <a href="http://jboss.org/gatein">GateIn Portal </a>which applies to Enterprise Portal Platform (EPP) in most cases as well. Here is a compilation of those docs in one place:<br />
<br />
<br />
<ul style="text-align: left;"><li>How to Create a New Portal on existing portal container with starter maven project: <a href="http://community.jboss.org/wiki/Createanewportalusingextension">http://community.jboss.org/wiki/Createanewportalusingextension</a> </li>
<li>How to Create a New Portal Container with starter maven project: <a href="http://community.jboss.org/wiki/Createanewportalcontainerusingextension">http://community.jboss.org/wiki/Createanewportalcontainerusingextension</a></li>
<li>How to customize landing page on login and logout based on user's role <a href="http://community.jboss.org/wiki/Redirectausertopageonloginlogoutbasedonrole">http://community.jboss.org/wiki/Redirectausertopageonloginlogoutbasedonrole</a></li>
<li>A community member took a different approach of creating a new portal without using extension : <a href="http://community.jboss.org/wiki/StepsToCreateANewPortalFromSample-Portal">http://community.jboss.org/wiki/StepsToCreateANewPortalFromSample-Portal</a></li>
<li>Send email to admin when a user registers or when there is x number of successive failed login attempts. See <a href="http://community.jboss.org/wiki/Sendingemailtoportaladministratorwhennewuserisregistered">http://community.jboss.org/wiki/Sendingemailtoportaladministratorwhennewuserisregistered</a> This is scheduled in next version of GateIn but you can try yourself by looking at <a href="https://issues.jboss.org/browse/GTNPORTAL-1805">https://issues.jboss.org/browse/GTNPORTAL-1805</a></li>
<li>An example of Spring MVC Portlet. The complete guide is at <a href="http://anonsvn.jboss.org/repos/qa/people/mcupak/svn-browser/README.txt">guide</a> and you can check out the maven project at <a href="http://anonsvn.jboss.org/repos/qa/people/mcupak/svn-browser">http://anonsvn.jboss.org/repos/qa/people/mcupak/svn-browser</a> as well.</li>
</ul><br />
The first two articles use extension mechanism which means that there is no or very very minimal change to OOB GateIn. I believe these docs should help you do an efficient customization of GateIn for your use.<br />
<br />
</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-57066623636994434412011-02-16T08:25:00.000-08:002011-02-16T08:27:16.714-08:00JBoss PortletBridge talk at Austin JUG<div dir="ltr" style="text-align: left;" trbidi="on">Come hear yours truly talk about JBoss Portletbridge at this month's Austin JUG meeting on Feb 22. The details of talk is at <a href="http://austinjug.org/index.jsp?p=events-20110222">http://austinjug.org/index.jsp?p=events-20110222</a> There will be free pizza and thanks to Red Hat for sponsoring my talk. <br />
<br />
On personal note, as part of my <a href="http://www.eejot.org/">Eejot (www.eejot.org)</a> effort, pls bring any old laptop you have that you are not using too much. You can tax deduct your contribution.</div><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-56235810159824007132010-12-06T10:46:00.000-08:002010-12-06T10:46:17.731-08:00Thoughts on recent Hudson trademark issuesRecently I have seen several tweets and blogs on forking Hudson and I also come across <a href="http://www.theregister.co.uk/2010/12/03/oracle_doesnt_own_hudson/">this article </a> on how Oracle is trying to assert its trademark on Hudson. This trademark thing simply disgusts me to say the least. <br />
<br />
I have been involved with Hudson from very early days and I think my first post to Hudson's user mailing list was in early 2007 and I even wrote a <a href="http://hudson.361315.n4.nabble.com/hudson-portlet-td367819.html">little portlet</a> that aggregated data from Hudson. I am not a kind of guy who tries to get his head around copyright issues and different OSS licenses but I always understood that<br />
<br />
<ul><li>Hudson started as Kohsuke Kawaguchi's pet project and he worked on top of his regular day job</li>
<li>Kohsuke did and still does an awesome job of being involved with community and as a result got several committers and plugin developers</li>
<li>Hudson got popular enough that Sun thought it deserved Kohsuke's full attention and they also started selling support for it.</li>
</ul>So more or less Hudson has been a perfect example of OSS where both project and community have had mutual relationship. Why would anyone want to impose a trademark on it? Oracle has been in news mainly for bad reasons among java community and this simply asserts why java community does not trust Oracle to be a good steward for Java. Leave Hudson as it is Oracle and start working with community, not against it. !!<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com2tag:blogger.com,1999:blog-8195620012319482647.post-3791200874671952132010-11-17T20:18:00.000-08:002010-11-17T20:18:17.044-08:00Richfaces : ReThink Before ReRenderSometimes when you go deeper into a framework or a tool , you tend to take beginner stuff for granted. That bit me today for a while before I could get my head around it. ;-)<br />
<br />
When using Ajax, it's a well known fact that for you to manipulate a DOM element, that element needs to be present. Same rule applies when you are using reRender in Richfaces as well. Let's take a look at following code snippet:<br />
<br />
<pre><rich:panel header="Add New Application">
<h:outputText value="App Name " />
<h:inputText size="20" id="appNameInput" value="#{appConfigBean.currentApp.appName}" />
<a4j:commandButton id="new_app_submit" action="#{appConfigBean.<b>addNewApp</b>}"
value="Add" reRender="<b>appDetails</b>" />
</rich:panel>
<h:panelGrid columns="2" id="<b>appDetails</b>"
rendered="#{appConfigBean.<b>renderDetail</b>}">
<h:outputText value="Some stuff"/>
</h:panelGrid>
</pre><br />
<br />
The <b>addNewApp</b> method in backing bean sets <b>renderDetail</b> to true which initially was false. So when you click Add button, you would expect reRender to kick in and show the panelGrid with id appDetails. Nope. It does not happen. From second paragraph you might have understood the reason already. But here is a more detailed explanation.<br />
<br />
Since initially, renderDetail boolean is set to false, when the page is first loaded, the html for panelGrid never gets rendered hence there does not exist a DOM element with id appDetails and reRender does not know what to update.<br />
<br />
To fix this, the easiest and probably the best solution is to surround panelGrid with a4j:outputPanel and you would put this output panel's id for reRender to do its magic. Here is the updated code:<br />
<br />
<pre>
<a4j:commandbutton id="new_app_submit">
action="#{appConfigBean.addNewApp}" value="Add"
reRender="<b>appDetailOutputPanel</b>" /&gt;
<a4j:outputpanel id="<b>appDetailOutputPanel</b>">
<h:panelgrid columns="2" id="appDetails">
rendered="#{appConfigBean.renderDetail}"&gt;
<h:outputtext value="Some stuff"></h:outputtext>
</h:panelgrid>
</a4j:outputpanel>
</pre><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-79061826760033173492010-11-02T10:29:00.000-07:002010-11-02T10:29:35.886-07:00Tips when using AWS sdk with JBoss AS + GateInWhile working on a really cool portlet for <a href="http://www.jboss.org/gatein/">GateIn</a> that uses <a href="http://www.quartz-scheduler.org/">Quartz scheduler </a>and <a href="http://github.com/amazonwebservices/">AWS sdk</a> which I am going to unveil to the rest of the world in few days ;-), I came across a weird problem. :<br />
<br />
<code><br />
Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.xml.xpath.XPath.setNamespaceContext(Ljavax/xml/namespace/NamespaceContext;)V" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/quartz/xml/XMLSchedulingDataProcessor, and the class loader (instance of <bootloader>) for resolved class, javax/xml/xpath/XPath, have different Class objects for the type javax/xml/namespace/NamespaceContext used in the signature</bootloader><br />
</code><br />
<br />
This kind of error obviously suggests some conflict with classloader and that was the case in this scenario too. I initially thought it must be something with quartz because I am using Quartz's XMLSchedulingDataProcessorPlugin but looks like that dependency comes from AWS sdk. To get it working, I simply removed stax-api-1.0.1.jar from WAR file and portlet deployed fine. The conflict happens because GateIn 3.0.1.GA + JBoss AS 5 combination has stax-api.jar under GateIn-3.1.0-GA/lib/endorsed which means StAX library is a system-wide library.<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-85194371324317680282010-09-21T08:52:00.000-07:002010-09-21T08:52:24.706-07:00How to configure GateIn with Amazon RDS !!Couple of weeks back <a href="http://www.jboss.org/stormgrind.html">JBoss Stormgrind</a> project created an <a href="http://www.jboss.org/stormgrind/downloads/stormfolio.html">AMI (<b><span class="value">ami-0cda3165) </span></b></a>for <a href="http://www.jboss.org/gatein">GateIn 3.1.0.Final</a> . If you have created an Amazon's EC2 instance from existing AMI before, creating a GateIn EC2 instance is no different. When an instance is running, you can access the default portal at URL which will look something like http://ec2-75-101-229-18.compute-1.amazonaws.com:8080/portal/ Don't try accessing the URL, it will go to /dev/null ;-) If you ssh into your instance, you can see JBoss+GateIn bundle at /opt/gatein-3.1.0.FINAL. By default, GateIn comes bundled with HSQLDB but normally people have a separate instance of DB such as MySQL running on separate server so here I am going to show you how you can configure Amazon RDS aka MySQL 5.1 with your GateIn instance running in cloud. <br />
<br />
1. In AWS management console, search for Gatein or you can directly enter ami-0cda3165. In subsequent window pick your availability zone and select instance type as "Small" which is enough to use GateIn for smaller use case and lighter load. Then select your key-pair, security group. Make sure your security group has port 8080 turned on. Ultimately, the details of instance should look similar to following screenshot:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_FKMrWUn8IkU/TJZpjRYCR-I/AAAAAAAAADk/l1H8h2g7T8w/s1600/aws-launch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/_FKMrWUn8IkU/TJZpjRYCR-I/AAAAAAAAADk/l1H8h2g7T8w/s320/aws-launch.png" /></a></div><br />
<br />
2. Launch your instance and when AWS console says instance is running, you should be able to access the GateIn's landing page at http://ec2-75-101-229-18.compute-1.amazonaws.com:8080/portal/ This verifies that we have GateIn AMI working properly which is running atop HSQL.<br />
<br />
3. Now, let's create a RDS instance. Launch DB instance wizard under Amazon RDS tab, select instance class as small, size 5G, give a name to your DB instance (this is not the schema name in case you are wondering) e.g. gateinmysql and of course master userid and password. In next window of wizard, give a DB name which is schema name. For availability zone, select the same zone you selected in step 1. This means that both GateIn and DB servers are collocated which will give you a better network QoS. Your configuration should look something like following:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_FKMrWUn8IkU/TJZtfEu3rRI/AAAAAAAAADs/X64XZQQuCO0/s1600/aws-rds.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/_FKMrWUn8IkU/TJZtfEu3rRI/AAAAAAAAADs/X64XZQQuCO0/s320/aws-rds.png" /></a></div>Launch the DB, go get a cup of coffee because it takes a while for Amazon to launch a DB instance. When it's runnig, your DB server name should look like gateinmysql.ck0mw2jbysdo.us-east-1.rds.amazonaws.com<br />
<br />
4. Now we need to hook 1 & 3 together. For this, let's ssh into the GateIn instance and stop GateIn server. We then modify the file, /opt/gatein-3.1.0.FINAL/server/default/conf/gatein/configuration.properties with the details from screenshot in 3. You can see complete detail of configuring GateIn with MySql at <a href="http://docs.jboss.com/gatein/portal/3.1.0-FINAL/reference-guide/en-US/html_single/index.html#sect-Reference_Guide-Database_Configuration">GateIn 3.1 reference guide. </a><br />
<br />
5. Copy (scp or wget) MySQL jdbc driver to /opt/gatein-3.1.0.FINAL/server/default/lib<br />
<br />
6. Delete data, log, tmp, work folders from /opt/gatein-3.1.0.FINAL/server/default so that we have a clean server again.<br />
<br />
7. Start GateIn server by doing "bash run.sh -c default -b 0.0.0.0". After couple of minutes depending on how good network connection between GateIn & RDS is, you should be able to see your portal running again at the URL you saw in 2. You can also use mysql-administrator in your laptop/desktop to see the tables and data GateIn created during startup.<br />
<br />
Unless you are a zombie, you would not want to repeat this process every time you need to run GateIn with RDS. You should create your own GateIn AMI based on all modifications you have done. The feature I liked about RDS is that you can take a snapshot of database and relaunch again. Amazon preserves the RDS public server name which means that configuration changes that you made on 4 would continue to work. <br />
<br />
Please let me know if you run into any problem when you to try to do yourself and I will update this blog accordingly. Happy clouding and portaling.<br />
-----------------<br />
Help me in my mission at <a href="http://www.eejot.org/">http://www.eejot.org</a><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-16685911153739018812010-09-12T22:29:00.000-07:002010-09-12T22:29:57.106-07:00How to debug a portlet in GateIn !!Lately I have seen few questions on how to use an IDE to develop and debug a portlet in <a href="http://community.jboss.org/en/gatein?view=discussions">GateIn user forum</a>. The simplest answer is: it's similar to how you develop and debug a regular (jsp, servlet, jsf etc) web application. But I am going to walk you through one example of doing the same using plain Eclipse (or JBoss Tools ) and GateIn Portal using remote debugging of the upcoming Jasper portlet that is still a work in progress.<br />
<br />
<div style="background-color: white; color: black;"><u><b>1. Import or create a project in eclipse</b></u></div><br />
Nothing much to add here..it's like any standard java project. You can see further details for creating a new project at <a href="http://docs.jboss.org/tools/whatsnew/portlet/portlet-news-1.0.0.Alpha1.html">http://docs.jboss.org/tools/whatsnew/portlet/portlet-news-1.0.0.Alpha1.html</a> In this example, I am going to import the mavenized jasper project from http://anonsvn.jboss.org/repos/qa/people/vrockai/jasper-sample-portlet/<br />
<br />
<u><b>2. Deploy the portlet into GateIn</b></u><br />
<br />
Since this is a maven project, doing a maven install will create a .war file which we will deploy or copy to $GATEIN_HOME/server/default/deploy.<br />
<br />
<u><b>3. Preapre GateIn for debugging</b></u><br />
Uncomment JPDA section for remote socket debugging in $GATEIN_HOME/bin/run.conf<br />
<code><br />
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket, <b>address=8787</b>, server=y,suspend=n"<br />
</code><br />
<br />
Please note the <b>port number</b> here. You can change it if you have any conflict on that port.<br />
<br />
<u><b>4. Start GateIn</b></u><br />
You simply do "bash run.sh" on Linux/Unix or run.bat on Windows.<br />
<br />
<u><b>5. Hook up Eclipse with GateIn server</b></u><br />
In eclipse, select Run->Debug Configurations->Remote Java application and click on "New Launch Configuration Icon" which should show the following screen. Please change the port number from Step 3. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_FKMrWUn8IkU/TI2sh3c3mZI/AAAAAAAAADU/8RRihgUnVXg/s1600/remote-debug.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/_FKMrWUn8IkU/TI2sh3c3mZI/AAAAAAAAADU/8RRihgUnVXg/s320/remote-debug.png" /></a></div>Click Debug. You should not get an error if eclipse is able to connect to the socket on port 8787.<br />
<br />
<u><b>6. Add portlet to a page</b></u><br />
As of GateIn 3.1.0, there is no "simple" way of adding a portlet to a page using XML similar to how it was in JBoss Portal so we are going to use GateIn's user interface to do that. You can see how to do that at <a href="http://docs.jboss.com/gatein/portal/3.1.0-FINAL/user-guide/en-US/html_single/index.html#chap-User_Guide-Portal_Administration">http://docs.jboss.com/gatein/portal/3.1.0-FINAL/user-guide/en-US/html_single/index.html#chap-User_Guide-Portal_Administration</a> Please ask in user forum if you need help with this. In my case, I added this to home page. I can see the portlet when I visit the home page. However since we did not put any break point, eclispe does not care at this point<br />
<br />
<u><b>7. Add a break point</b></u><br />
<br />
I am going to add a break point on the first line of code in doView method of JasperPortlet class knowing that this method is always going to be called for normal viewing of this portlet.<br />
<br />
<u><b>8. See it in action</b></u><br />
<br />
Let's refresh the page which should call doView method again and eclipse should prompt me to go to Debug perspective. Here is screenshot.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_FKMrWUn8IkU/TI2z6CmherI/AAAAAAAAADc/4l9MFYkzBmo/s1600/debug-persp.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/_FKMrWUn8IkU/TI2z6CmherI/AAAAAAAAADc/4l9MFYkzBmo/s320/debug-persp.png" /></a></div>Happy debugging.<br />
------------------<br />
Please help me in my effort of computer literacy in Nepal at <a href="http://www.eejot.org/">http://www.eejot.org</a><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-36501967608628333342010-08-19T12:07:00.000-07:002010-08-19T12:22:59.095-07:00Hot eclipse tip of the dayIn eclipse, when you hit F3 while your cursor is over some code in .java file, it will jump to its declaration. It's all good except in the case of an interface. For a method in interface, most of time you want to see its implementation not its declaration. There are few ways to work around this:<br /><br />- Ctrl+mouse over the text will show options to jump to declaration or implementation.<br /><br />- Ctrl+t will also show you options for both interface and its implementation.<br /><br />First one requires me to use mouse, second one is not intuitive because I am used to hitting F3 to do similar operation. Ideally, you would like to see some combination of F3 doing its job. The <a href="http://eclipse-tools.sourceforge.net/implementors/"><span style="font-weight: bold;">Implementor</span></a>s plugin does exactly that. Now when I hit, ALT+F3 it goes directly to its implementation.<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-7610156696192178672010-08-06T09:20:00.000-07:002010-08-06T11:18:22.467-07:00Some new kind of entertainment for your portalMost of us like and love movies and we have some favourite stars and sometimes we even hang their posters. Even folks at prison get to do that; remember Rita Hayworth in Shaswshank Redemption. Now if you don't know who Rita Hayworth is and which movie I am talking about, you would probably google it and your search would more likely take you to IMDB or Wikipedia - yaaaawn ;-) Now imagine not having to do that and getting those information in your own portal. YE !!<br /><br />Introducing Netflix portlet. Since picutures are worth thousand words, here are some screenshots with details of Shawshank Redemption. For a movie and TV series, the portlet currently shows its synopsis, cast, ratings, awards, poster if available.<br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_FKMrWUn8IkU/TFw9relXhXI/AAAAAAAAAC8/YdWmuSk_Wd8/s1600/netflix-movie.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 190px;" src="http://3.bp.blogspot.com/_FKMrWUn8IkU/TFw9relXhXI/AAAAAAAAAC8/YdWmuSk_Wd8/s320/netflix-movie.png" alt="" id="BLOGGER_PHOTO_ID_5502340661893367154" border="0" /></a><br />For an actor, it shows his/her biography, filmography and of course a picture if available. Here is a screen shot of portlet with details of one of the actors I like.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_FKMrWUn8IkU/TFxA7JQwofI/AAAAAAAAADE/TKc60PLR9V8/s1600/netflix-actor.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 190px;" src="http://3.bp.blogspot.com/_FKMrWUn8IkU/TFxA7JQwofI/AAAAAAAAADE/TKc60PLR9V8/s320/netflix-actor.png" alt="" id="BLOGGER_PHOTO_ID_5502344229582578162" border="0" /></a><br />Now some interesting details: Portlet consumes data using Netflix's webservices API hence to have this portlet running on your server you need to have proper key which you can get from <a href="http://developer.netflix.com/docs/Security">Neflix's Dev page</a> and when you start your server, you simply add <code> -Dnetflix.consumer.key=blah -Dnetflix.consumer.secret=blahblah </code> as JVM parameters. Portlet is based on <a href="http://www.jboss.org/richfaces">JBoss Richfaces 3.3.3.Final</a>, <a href="http://www.jboss.org/portletbridge">JBoss PortletBridge 2.0.0.Final</a> and has been tested with <a href="http://www.jboss.org/gatein">GateIn Portal</a> and J<a href="http://www.jboss.com/products/platforms/portals/">Boss Enteprise Portal Platform 5</a>. The source code of this portlet can be downloaded from <a href="http://anonsvn.jboss.org/repos/qa/prabhat/netflix/">http://anonsvn.jboss.org/repos/qa/prabhat/netflix</a><br /><br />Disclaimer: This portlet is not officially supported by <a href="http://www.jboss.com/">JBoss, by Redhat.</a><br /><br />Help support my mission: <a href="http://www.eejot.org">http://www.eejot.org</a><div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-10358926785761328522010-06-25T10:10:00.000-07:002010-06-25T10:14:21.801-07:00Richfaces Presentation at Austin JUGI will be giving a 45-min presentation on <a href="http://www.jboss.org/richfaces">JBoss Richfaces </a>at Austin JUG on June 29 starting at 7 PM. More details at <a href="http://austinjug.org/index.jsp?p=events-20100629">http://austinjug.org/index.jsp?p=events-20100629</a> I hope to see you there if you are in town.<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0tag:blogger.com,1999:blog-8195620012319482647.post-67580764567371181022010-04-23T13:28:00.000-07:002010-04-23T14:13:24.906-07:00Java's Language discrimination against NepaliI will let following code and it's output do the talking:<br /><pre><br /><span style="color: rgb(51, 0, 153);">System.out.println ("Korean testing: ");</span><br /><span style="color: rgb(51, 0, 153);">Locale locale = new Locale("ko");</span><br /><span style="color: rgb(51, 0, 153);">System.out.println("DisplayName in current locale:" + locale.getDisplayLanguage()); </span><br /><span style="color: rgb(51, 0, 153);">System.out.println("Display Name in Native: " + locale.getDisplayLanguage(locale));</span><br /><span style="color: rgb(51, 0, 153);"> </span><br /><span style="color: rgb(51, 0, 153);">System.out.println ("\n French testing: ");</span><br /><span style="color: rgb(51, 0, 153);">locale = new Locale("fr");</span><br /><span style="color: rgb(51, 0, 153);">System.out.println("DisplayName in current locale:" + locale.getDisplayLanguage()); </span><br /><span style="color: rgb(51, 0, 153);">System.out.println("Display Name in Native: " + locale.getDisplayLanguage(locale));</span><br /><span style="color: rgb(51, 0, 153);"> </span><br /><span style="color: rgb(51, 0, 153);">System.out.println ("\n Hindi testing: ");</span><br /><span style="color: rgb(51, 0, 153);">locale = new Locale("hi");</span><br /><span style="color: rgb(51, 0, 153);">System.out.println("DisplayName in current locale:" + locale.getDisplayLanguage()); </span><br /><span style="color: rgb(51, 0, 153);">System.out.println("Display Name in Native: " + locale.getDisplayLanguage(locale));</span><br /><span style="color: rgb(51, 0, 153);"> </span><br /><span style="color: rgb(51, 0, 153);">System.out.println ("\n Nepali testing: ");</span><br /><span style="color: rgb(51, 0, 153);">locale = new Locale("ne");</span><br /><span style="color: rgb(51, 0, 153);">System.out.println("DisplayName in current locale:" + locale.getDisplayLanguage()); </span><br /><span style="color: rgb(51, 0, 153);">System.out.println("Display Name in Native: " + locale.getDisplayLanguage(locale));</span><br /></pre><br />Here is the output:<br /><pre style="color: rgb(51, 0, 153);">Korean testing:<br />DisplayName in current locale:Korean<br />Display Name in Native: 한국어<br /><br />French testing:<br />DisplayName in current locale:French<br />Display Name in Native: français<br /><br />Hindi testing:<br />DisplayName in current locale:Hindi<br />Display Name in Native: हिंदी<br /><br />Nepali testing:<br />DisplayName in current locale:Nepali<br />Display Name in Native: Nepali<br /></pre>What the heck?? I understand that Nepali is not as widely spoken as other languages that are shown above but given that you can show Hindi in "Devnagiri script" and Nepali also shares the same script, why would Java not apply that to Nepali as well? Do I smell discrimination here? ;-)<br /><br />Just for curious mind, this came up when I was trying to see why Nepali is not written as नेपाली in "Change Language" dialog box in GateIn.<div class="blogger-post-footer">Help me with my effort at http://www.eejot.org</div>Prabhat Jhahttp://www.blogger.com/profile/10962036079302803908noreply@blogger.com0