Wednesday, December 16, 2009

Spring Framework Presentation : A case study of one of my projects

In my current organization Aftek Limited I have used Spring Framework in one of my projects (lets call it as SomeProject since I can't disclose the name of the project!). To smoothen the learning curve I have been asked to present a case study of Spring.

The following PPT is the slightly modified version of the presentation. As usual comments are welcome! :-)

Friday, December 04, 2009

JBoss application server tuning and slimming

In one of my projects I have got some time to play with JBoss to “tune” it. I will rather say to “slim” it!
The project was basically a JEE application involving EJB 3.0 and Flex with BlazeDS. Here are some of the things which I noticed / performed …

  • Use latest version of JBoss (jboss-5.1.0.GA-jdk6 if using Java 6. You would face problems related to web services java.lang.UnsupportedOperationException: setProperty
    must be overridden by all subclasses of SOAPMessage something of this sort if you try to use JBoss 5 with Java 5. Refer: http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4194526 … Thanks Ashwin Shah for figuring out this!)
  • Set following JVM arguments in run.conf.bat
    • set "JAVA_OPTS=-Xms512M -Xmx512M -XX:MaxPermSize=256M -XX:PermSize=256M -XX:ReservedCodeCacheSize=128M"
    • The meaning of above parameters can be found at http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
    • Above settings are for me and you may have your own values for JVM parameters.
    • To know overall Java memory management or garbage collection search google!
  • Configure log4j as …
    • Use minimum required pattern as
    • param name="ConversionPattern" value="%d{yyyy MM dd HH:mm:ss:SSS}, [%-5p], [%t:%x], %c, %m%n"
    • Use INFO threshold by setting property in run.conf.bat as
    • set "JAVA_OPTS=-Djboss.server.log.threshold=INFO"
    • Disable console logs as
    • just XML comment: appender-ref ref="CONSOLE"
  • Slim web container as
    • If AJP connector is not getting used then disable its "connector" entry from server.xml
    • If only HTTPS is used and not HTTP then disable HTTP "connector" entry from server.xml
  • Remove unused services by removing following files from JBoss default configuration
    • cache-invalidation-service.xml (needed in case of clustered deployment)
    • hdscanner-jboss-beans.xml (hot deployment related)
    • http-invoker.sar (invoking rmi over http)
    • monitoring-service.xml (monitoring alerts)
    • profileservice-jboss-beans.xml (profile service)
    • profileservice-secured.jar (profile service)
    • properties-service.xml (setting jmx properties)
    • quartz-ra.rar (scheduler)
    • schedule-manager-service.xml (scheduler)
    • scheduler-service.xml (scheduler)
    • uuid-key-generator.sar (uuid generator)
  • Remove Jboss timer services (ejb2-timer-service.xml and ejb3-timerservice-jboss-beans.xml) if not using MDB. If the bug https://jira.jboss.org/jira/browse/EJBTHREE-1880 gets fixed then you can remove timer services even if you are using MDB
  • Well there are many more things which can be found at
  • That’s it! (More things coming later … when? Don’t know ;-))

Some explanation on "JVM not able to create native threads":
There is a nice article which talks about this issue: http://www.egilh.com/blog/archive/2006/06/09/2811.aspx

The article summary is as follows
  • Let’s say we have a 32 bit Windows machine with 4 GB of RAM. In 32 bit windows every process has a max limit of 2 GB virtual memory. So the JVM has a max limit of 2 GB.
  • If we have allocated 1.5 GB memory to JVM heap then only 500 MB memory is still available to JVM. Out of this say JVM use 100 MB for other purposes like linking etc then JVM has 400 MB left.
  • In java when we create a thread, java creates a thread object in JVM memory and also creates operating system thread. Now from java 1.5 onward each thread has its own stack of 1 MB.
  • So according to above statistics, JVM is only able to create maximum 400 threads using 400 MB memory left. And if thread count is increased JVM would give an error “unable to create native threads”!.
  • Hence we have to decrease the JVM heap memory size to increase the thread count.
Hope this helps!

Wednesday, June 04, 2008

Mentoring FAQs

Hello all this is a summary of the discussion I had with DR regarding “mentoring” scheme. I have compiled the discussion as FAQ.

Note: To know more about Mentoring please check out: this url

  • What should be the approach towards the technical problem solving of freshers?
    • Typically mentor should not be the problem solver for a freshers because freshers can anyways achieve this using google J. In some ways, mentor is to help fresher find better solution quickly. Moving the fresher aside and writing the code yourself on his desktop is not a very effective way of teaching. Neither is it sustainable. Mentor should tell the freshers the proper approach towards the problems solving so that freshers should be able to solve the similar problems next time.
    • Mentor should guide the freshers to use proper documentation while solving the problems. Trial-and-error approach is discouraged when it delays things and brings about sub-optimal solution. E.g. Use of Java Docs, Specs, Man pages are preferred over google contents and forums.
    • In general, it is a good idea to let the fresher commit mistakes. But this has to be time boxed. We cannot let freshers make mistakes which will affect business. But some mistakes need to be allowed and budgeted for as these are necessary parts for anyone to gain confidence.

  • How to tackle freshers who make same mistakes very often even told 100 times?
    • Very first thing that mentor needs to do is to find out the root cause: why the person is making mistakes. There could be two reasons for two altogether different types of freshers.
      • One who make same mistakes because of their laziness but they have the capability of understanding / recognizing the problem and their solution.
        • To make the first type of freshers mature mentor will have to talk with them in person about their laziness and nature of “taking things granted”. But mentor should make sure that he/she conveys the message in proper way to freshers because keeping voice loud / becoming frustrated / showing anger never helps.
        • E.g. Mentor can tell the fresher that making same - same mistakes again and again just because of his negligence will create trouble for him. Rather being careful will only him to save his time; help him in his grades and hence eventually in his performance appraisals; he will face few bugs in his implementation and will get a change to be shifted to new project/module and will get exciting work and opportunities. In short, always make sure that you are vocal about “what is in it for the fresher” to deliver better solution. If he sees value in it, he will do it.
      • Other who make same mistakes because of their inability to do “pattern-match” for the problem and its solution. This is basically skills and capability issue. People have different capabilities and some freshers just may not have the necessary analytical power, knowledge, or skills to tackle the issues resulting in repeated mistakes.
        • In this case as the fresher is not able to perform well will eventually get simpler work and will be shifted to non-critical tasks.
        • Only thing that we need to ensure is that every one works to the best of her potential. People’s potential will differ. So some will work better at the backend while others will be better off handling front-end etc. Mentor needs to be sensitive to this and should guide the fresher accordingly.

  • How to spend effective and fruitful time with freshers?
    • If the mentor is directly working with that fresher (e.g. same module/project) then his/her interaction with him will be good. But in cases where mentor is in different project/module then mentor needs to setup meetings (typically 3 times in a week (alternate day) of duration 60 mins) with freshers.
    • First few meetings will run for 60 or more mins but quickly – typically after first 2 or 3 weeks, the meetings can be of reduced duration and frequency. This is to ensure that fresher gets lot of attention when she starts – when the anxiety level is high. And later he gets more freedom – as she become more confident and experienced.
    • As the mentor is not working in same module / project mentor will not have the idea about what the freshers are doing. In such cases mentor should ask freshers about the work they did in last 2/3 days; the work they are going to do in next 2/3 days; how they implemented some feature; how they fixed some issue etc etc. Thus mentor can discuss the technical stuff in detail and can figure out whether the person is doing it properly or whether he needs some correction.

  • If mentor is mentoring freshers who are working with different project manager / lead then it might happen that for a given problem mentor will have a different (or better) solution than that of the existing project manager / lead. How to handle such situation because in such cases it’s possible that the fresher will get sandwiched?
    • In such a cases mentor should provide the proper solution no doubt. But should ask the fresher to talk about this approach with the existing project manager / lead and convince him for the solution. After all the delivery responsibility is with the current PM and mentor should not adversely affect that part!
    • It might happen that due to the communication gap or fresher’s limited understanding or some other reason the solution provided by mentor could be unsuitable. In such cases mentor should talk with the existing project manager / lead to reveal such communication gap. But ultimately fresher should implement what his PM tells him to though he must also learn correct things. Such communication gap should be communicated with mentor also otherwise mentor will lose insight for those particular projects / features.


  • Is the mentor supposed to assign work / task to freshers?
    • No. This is the project managers / leads responsibility. Mentor is there to guide the freshers on their technical / analytical growth and to communicate their issues / aspirations to proper person on proper time.


  • How to deal with issues and aspirations of freshers?
    • Mentor should immediately communicate issues of freshers to project manager which he thinks he can handle. E.g. I stay far away so it’s not possible for me to stay late in office. I can come early in office and can finish my work. In some critical cases if I have to wait late in office please make sure that someone will drop me to home etc etc. There is a possibility that due to direct line of command, fresher may hesitate to share such information with her PM. Mentor should facilitate such communication and make fresher more comfortable.
    • Same is applicable with aspirations. E.g. I want to work on better module where I can contribute more. Why don’t we use xyz technology / tool / library rather than this? etc etc.
    • In your project if you are using some old technology (E.g. postgres instead of oracle) which can be easily and sensibly replaced by something new. And if there is no reason that why you are using that particular old technology then you are free to migrate to newer one. However, the decision must be taken by the PM. Mentor has a responsibility to facilitate the fresher’s feelings and to ensure that she gets an answer from the PM.
    • In your project if you are using some third party libraries which can be easily developed in house; you can write a small (one page) requirement specification for the same and sent that to project manager stating its criticality and importance. Such in-house library / component development will create “new and exciting work” for freshers as well as for mentorsJ. Such development should be executed just as another project in organization by the manager otherwise it will loose its criticality.


  • There are mentors of various levels of experience ranging from 1 year to 5 years. Any comments?
    • True. There are various advantages of this approach.
      • Young mentors will get sense of responsibility and will now start improving on their communication / leading / technical skills because now they not only have to face their bosses but also to the freshers ;-)
      • Senior people will also not lose the common touch ;-)
      • Also we have an advantage here that we have given freedom to freshers to choose their mentor. So this adds one more responsibility over mentor’s shoulders.
      • The whole point is to expose freshers to various different points of views. We want to stress the fact that it is “okay” to have different opinion and different approach. What is more important is to be able to respect different opinions and develop skills to decide which (approach / style) works best for which circumstances.


  • Can mentor think independently?
    • Why mentor? Everyone should think independently! The more diverse people the fresher will deal with the more he/she will learn.


  • Whether mentor is supposed to evaluate the freshers?
    • No. This is project managers / leads responsibility.
    • Mentor should understand the strengths and weakness of freshers and should guide him/her accordingly.


  • Last question! How to manage your boss while doing all this?
    • Simple! By communicating with your boss’s boss – when things go wrong! :-) Everyone has to learn. Your boss and boss’s boss as well. Best way to make it happen is to talk, talk, talk! When you talk with your boss’s boss, either you would get some more insight in to why your boss is working in a particular manner. Or your boss will get some feedback about how she should work. Either ways, both you and your boss will form more trusting and comfortable relationship. Your boss’s boss will be facilitator in such a case!

About DR:

DR is our SVP Engineering. Apart from usual technical and managerial work in IT industry, DR is also involved in many social activities. He is a trustee of an NGO named Sanvedana. To know more about Sanvedana and participate in its great charity works please visit http://www.sanvedana.org/.

So looking forward to meet you guys at Sanvedana to take its mission ahead by one small step.

Thursday, May 01, 2008

Continuous Integration: Improving Software Quality and Reducing Risk

In November 2007 I attended a conference on Java Technology in Hinjewadi, Pune.
To know more about the conference visit:
Well, there I had attended the presentation on Continuous Integration from Paulo Caroli who is from ThoughtWorks. I was very impressed by the methodology he discussed with us. Then I decided to give it a try in my current project at Aftek. I will write later on my practical experiance about CI. But let me tell you in order to make my team aware of what CI exactly is I had given a small presentation. I though I would be a great idea to share that here on this space.

So here I go ... (and of course yes your suggestions / comments / critics are always welcome)