Archive for Development

Shell Script to Start and Stop JBoss

I was looking for a script to start and stop JBoss server on the Linux environment, but didn’t find anything that useful. I did find one for starting and stopping lighttpd server for our Rails applications and have been using it effectively. Even though I am not a shell script expert, I thought I will modify the script a bit and make use of it for JBoss. The main change that I had to make was to make the script wait until the server starts or stops. To make sure the server has successfully started, I had to tail the log file for one line until the last line contained the text “JBoss (MX MicroKernel) …….. Started”. To make sure the server stopped successfully I had to ensure the process was terminated completely. If you are in need of such a script, here it is.

Download JBoss start/stop Script

Some items you have to change in the script to work for your environment.

  • PIDFILE - File containing the process id. Change it to a location where you want to have this file.
  • STARTJBOSS - Command to start JBoss. Scan through this command in entire and make sure you have added the parameters necessary for your environment, set the minimum and maximum JVM heap, and also the server you want to start. You can get this information from the server log when you run JBoss using the run.sh script. The script assumes you have Java executable in the path.
  • LOGFILE - The server’s log file. Change it to a location where you want to have this file.

Additionally you might want to change line 32 to the right version of JBoss you are using. Make sure this line reflects exactly what you see in the server log at the end when JBoss completes starting the server. If it doesn’t match, this script will go in infinite loop.

An additional benefit I got after writing this script was to have our automated build scripts using Ant to deploy the applications on any box using the SSHExec tasks. Really cool and time saving.

Disclaimer - The script herein provided to you is “AS IS” without any warranties of any kind. The script has not been thoroughly tested under all conditions. I, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

Blink this Shell Script to Start and Stop JBoss at blinklist.com    Bookmark Shell Script to Start and Stop JBoss at blogmarks    Bookmark Shell Script to Start and Stop JBoss at del.icio.us    Digg Shell Script to Start and Stop JBoss at Digg.com    Fark Shell Script to Start and Stop JBoss at Fark.com    Bookmark Shell Script to Start and Stop JBoss at Furl.net    Bookmark Shell Script to Start and Stop JBoss at NewsVine    Bookmark Shell Script to Start and Stop JBoss at reddit.com    Bookmark Shell Script to Start and Stop JBoss at Simpy.com    Bookmark Shell Script to Start and Stop JBoss at Spurl.net    Bookmark Shell Script to Start and Stop JBoss with wists    Bookmark Shell Script to Start and Stop JBoss at YahooMyWeb

Comments (2)      Cosmos

Flex and Ant Build

One of our projects uses Flex 2 for our presentation layer. We were using Flex builder as the IDE to build the flex components, packaged it with the rest of the J2EE application as war and deployed it. As a practice with rest of the projects we wanted a build automation done in place for continuous integration, as well as saving time building and deploying it to different environments. We could get the ant scripts ready within no time for the J2EE piece of it as it was straightforward and we have done it numerous times. As far as flex goes even though flex ant tasks are available with documentation it wasn’t that easy for us to get things built as flex builder would do it. Sure the ant tasks built the swf files but when we deployed the application on the server we always got this error “RSL Error 1 of 1″ and nothing beyond that. Searching this error resulted in different reasons but nothing concrete in nature.

To be more exact, our application consisted of a Flex model folder containing action scripts common across the other Flex modules. So this had to be set as a run time shared library (RSL) rather than packaging it along with other modules. Packaging with other modules would make it work, but it becomes bulky and performance degrades because the model classes are loaded for each Flex package. To make it a RSL while building the flex components, the model has to be referred as RSL using the attribute in the task. We did this but only got the error mentioned above “RSL Error 1 of 1″. We were clueless at this point and tried out combination of attributes while compiling using mxmlc.

Our only hope remained in identifying what makes the build done by the flex builder make it work and the difference between the parameters it uses and what we use. We knew this because the size of SWF generated out of a Flex builder build was very different from the size that came out of our ant build. Because the build properties are GUI based, how to get what configuration flex builder uses and how it translates to the appropriate compiler options? After exploring the available compilation parameters with mxmlc, we found out the parameter -dump-config would dump the configuration used in a file. We added this parameter to the compiler parameters in the Flex compiler options as shown below in the screen.

dump config option

We compared the configuration that flex builder used versus what we had been using in the mxmlc task, only to find out there wasn’t much difference except for few of the compile time properties which was also present in the flex.config file we were using. The same RSL attribute was present making the model package as reference. We were back to square one wondering what could be the difference and what we are missing. After two days of struggle, a careful re-examination of the configuration in Flex builder when referring the model package in other packages revealed something. Take a look at the snapshot below.

Flex Build Path - Auto Extract SWF - True

The “Auto extract swf: true” was something that we could not find a translation when using the compc ant task and we could not find any documentation mentioning this in the flex ant tasks documentation. We were able to confirm that something is happening here again because of the size difference between what Flex builder generated versus what our ant build generated. There must be a way to produce the package exploded rather than having it packaged as one SWF, just like an exploded war file. Fortunately there was option to do this with the compc task when the directory attribute is set to true and the output attribute holds a directory value. When we were able to do this everything got revealed. Here is a snapshot of the directory structure.

compc output

A look at the files that got generated told us that the SWF that contained the model was having a name of “library.swf”, and when this directory was packaged and added as RSL, there is a mismatch in the reference. The flex runtime binary is looking for MyModel.swf while the only file present is library.swf. That should be the reason for the RSL Error. Also the size when Flex builder built the package was exactly equivalent to the size of the library.swf file present above. So that answers what “Auto extract swf: true” configuration does.

So our ant script was ready, we used one compc task to generate an exploded model directory. Picked the library.swf and copied it to the war with “MyModel.swf”. Another compc task to generate the model packaged so that we can refer it only for compilation for other flex models. Once we did this, everything worked perfectly. So here is the sample ant code (right click and save as, then open in an editor) that made the trick.

Hope this is useful for someone struggling with similar situation and it saves the head cracking time. If someone has found out an easier approach to this please pass that on, we would be happy to learn.

Blink this Flex and Ant Build at blinklist.com    Bookmark Flex and Ant Build at blogmarks    Bookmark Flex and Ant Build at del.icio.us    Digg Flex and Ant Build at Digg.com    Fark Flex and Ant Build at Fark.com    Bookmark Flex and Ant Build at Furl.net    Bookmark Flex and Ant Build at NewsVine    Bookmark Flex and Ant Build at reddit.com    Bookmark Flex and Ant Build at Simpy.com    Bookmark Flex and Ant Build at Spurl.net    Bookmark Flex and Ant Build with wists    Bookmark Flex and Ant Build at YahooMyWeb

Comments (3)      Cosmos

Javascript Event Order

A typical problem that developers face is handling an event of same type, when the elements are nested and both of them implement the same event. Suppose you have an element (say element 2) inside another element (say element 1). Let’s say both element 1 and element 2 implement the onclick event. When the user clicks on element 2, since it is nested, should the onclick event of element 1 get triggered first and then of element 2 or vice versa? Since the elements are nested and using the same event both the element’s event handler methods are called. The question is which one first.

Here is a link to a blog article “Event Order” which explains the problem, and the solution to it. Thanks to my friend and colleague, Narayanan who sent me this link when we faced the problem handling such a situation while developing Jiffle.

Blink this Javascript Event Order at blinklist.com    Bookmark Javascript Event Order at blogmarks    Bookmark Javascript Event Order at del.icio.us    Digg Javascript Event Order at Digg.com    Fark Javascript Event Order at Fark.com    Bookmark Javascript Event Order at Furl.net    Bookmark Javascript Event Order at NewsVine    Bookmark Javascript Event Order at reddit.com    Bookmark Javascript Event Order at Simpy.com    Bookmark Javascript Event Order at Spurl.net    Bookmark Javascript Event Order with wists    Bookmark Javascript Event Order at YahooMyWeb

Comments      Cosmos

Code Quality

I was introspecting myself after reading the article “Code Quality - Why Maintenance And Risk Management Are So Important to Developers” in DZone. It is a very interesting article and the points mentioned by Reiner Eischen are very much valid. As an architect I had been a victim to many such occasions. Because if risk management is not taken care early on it hits you bad once the application is live. When that happens and you want to trace back where the problem is, you got to understand what’s happening behind the scenes. It will take a long time for you to know what’s happening if the code is not documented. Additionally to what the author says, what I have observed is, developers usually get into the mode of writing draft code pieces to check if something works or not and copy it back to the mainstream code. When that happens, consciously or unconsciously they also forget about making it clean and writing a comment to that. What developers don’t realize is that they fall victim to a not understandable code later and spend more time to add or modify something. My 2 cents.

Blink this Code Quality at blinklist.com    Bookmark Code Quality at blogmarks    Bookmark Code Quality at del.icio.us    Digg Code Quality at Digg.com    Fark Code Quality at Fark.com    Bookmark Code Quality at Furl.net    Bookmark Code Quality at NewsVine    Bookmark Code Quality at reddit.com    Bookmark Code Quality at Simpy.com    Bookmark Code Quality at Spurl.net    Bookmark Code Quality with wists    Bookmark Code Quality at YahooMyWeb

Comments      Cosmos

Programming - Is it a child’s play?

I stumbled upon the site c-jump. It is a site that markets the board game c-jump. c-jump is for children to learn the basics of programming languages such as C, C++ and Java. Interestingly not just children, even grown ups who enter the software industry would need to play this. There is this blind programming culture, wherein developers create programs not understanding the basics and using code copy paste. It is neither going to help the individual, the project nor the organization in the long run. As computer science is becoming a main stream subject in schools, acquiring programming skill is not just limited to someone studying a computer science course. It does not matter at what age one learns programming, what matters is learning the basics right. Ironically I also stumbled upon an image that has relevance to this subject. Here is the link to the image. Is programming a child’s play? :-)

Happy weekend.

Blink this Programming - Is it a child's play? at blinklist.com    Bookmark Programming - Is it a child's play? at blogmarks    Bookmark Programming - Is it a child's play? at del.icio.us    Digg Programming - Is it a child's play? at Digg.com    Fark Programming - Is it a child's play? at Fark.com    Bookmark Programming - Is it a child's play? at Furl.net    Bookmark Programming - Is it a child's play? at NewsVine    Bookmark Programming - Is it a child's play? at reddit.com    Bookmark Programming - Is it a child's play? at Simpy.com    Bookmark Programming - Is it a child's play? at Spurl.net    Bookmark Programming - Is it a child's play? with wists    Bookmark Programming - Is it a child's play? at YahooMyWeb

Comments      Cosmos

Behaviour-Driven Development

Until a couple of days, I didn’t know there was something called  Behaviour-Driven Development (BDD). I realized and was quite impressed with how BDD can add value in combination with Test Driven Development (TDD). Below are the principles of BDD, copied from its home page.

  1. It is all behavior - Business and Technology should refer to the same system in the same way
  2. Where is the business value - Any system should have an identified, verifiable value to the business
  3. Enough is enough - Up-front analysis, design and planning all have a diminishing return

Theory is good but we understand concepts better with examples. In fact before I read about BDD at its home page I learnt how to do BDD when I read an article on “How I Learned to Love Testing” presentation, on Rails Envy. The presentation (a 30 minute quicktime movie) explains two aspects. The first aspect is why writing test code is important and how you can get to a mode from “I don’t like writing tests” to “I love testing”. The second aspect is on the BDD using the RSpec plugin for Rails. The concept is good and I really see a value, particularly the 1st principle which would help technical people start thinking and speaking in business terms throughout the development of a system. I am yet to try my hands on RSpec but based on the presentation and the links provided in the above article, I am keen on trying it soon on a project.

Blink this Behaviour-Driven Development at blinklist.com    Bookmark Behaviour-Driven Development at blogmarks    Bookmark Behaviour-Driven Development at del.icio.us    Digg Behaviour-Driven Development at Digg.com    Fark Behaviour-Driven Development at Fark.com    Bookmark Behaviour-Driven Development at Furl.net    Bookmark Behaviour-Driven Development at NewsVine    Bookmark Behaviour-Driven Development at reddit.com    Bookmark Behaviour-Driven Development at Simpy.com    Bookmark Behaviour-Driven Development at Spurl.net    Bookmark Behaviour-Driven Development with wists    Bookmark Behaviour-Driven Development at YahooMyWeb

Comments      Cosmos

Down for Maintenance

Here is another interesting area to look at during software development lifecycle. Once a web application goes live it is not the end. In fact its life starts getting serious once it goes live. New feature releases, updates and maintenance are part of an application’s life cycle. Unless and otherwise it is a critical application every other application would go offline during sometime of the year. During that time you do not want the users to get a “Cannot find …” error. The standard is to post a static page that says “The site is down for maintenance. We will be back shortly”. Today I was stumbling upon few sites and got into Whisher, looks like they were down for maintenance. See below the screenshot of their message. Makes a difference isn’t it?

Down for Maintenance?

Blink this Down for Maintenance at blinklist.com    Bookmark Down for Maintenance at blogmarks    Bookmark Down for Maintenance at del.icio.us    Digg Down for Maintenance at Digg.com    Fark Down for Maintenance at Fark.com    Bookmark Down for Maintenance at Furl.net    Bookmark Down for Maintenance at NewsVine    Bookmark Down for Maintenance at reddit.com    Bookmark Down for Maintenance at Simpy.com    Bookmark Down for Maintenance at Spurl.net    Bookmark Down for Maintenance with wists    Bookmark Down for Maintenance at YahooMyWeb

Comments (2)      Cosmos

What Gets Displayed Matters

Error and exception handling is a part and parcel of any software development. One might be handling the errors and exceptions technically well and make it easy to troubleshoot but the user experience also matters. If something doesn’t work and the user is shown an error page obviously the first reaction would be a let down feeling. But if at all something can calm the end user a bit, it would be in a way the error message is displayed. I was trying to open a document from my Gmail in Google Docs and I got an error page (snapshot below). Though I was disappointed the document was not opening, the message caught my attention and made me smile.

Google Docs Error Page

Blink this What Gets Displayed Matters at blinklist.com    Bookmark What Gets Displayed Matters at blogmarks    Bookmark What Gets Displayed Matters at del.icio.us    Digg What Gets Displayed Matters at Digg.com    Fark What Gets Displayed Matters at Fark.com    Bookmark What Gets Displayed Matters at Furl.net    Bookmark What Gets Displayed Matters at NewsVine    Bookmark What Gets Displayed Matters at reddit.com    Bookmark What Gets Displayed Matters at Simpy.com    Bookmark What Gets Displayed Matters at Spurl.net    Bookmark What Gets Displayed Matters with wists    Bookmark What Gets Displayed Matters at YahooMyWeb

Comments      Cosmos

· « Previous entries

Creative Commons License  This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.