GlassFish Auto Deployment and Hot Deployment

October 23rd, 2007 by Amit

There are several ways to deploy a GlassFish application. To speed up development/debuging we need a way to instantly deploy web applications. One of the ways is to use hot deployment feature, another lesser known feature is ‘directory deployment’. You simply point GlassFish to your development directory and let it pick up and deploy application from there. No packaging and re-deoploying hassles. The catch is whenever you want to re-deploy your application you just need to ‘touch’ a file called ‘.reload’ which should be present in your web folder.
Following is the command and directory structure you can use.
–|myproj
–|–|src
–|–|web
–|–|–|WEB-INF
–|–|–|–lib
–|–|–|–classes
–|–|–|–web.xml
–|–|.reload

GLASS_FISH_HOME/bin/asadmin deploydir full_path_to_you_web_folder

If you are using Eclipse or NetBeans make sure that they put the class files in web-inf/class folder after compiling.

Evaluating / Comparing NetBeans and Eclipse EE for Java EE development

October 19th, 2007 by Amit

Although we are ‘big’ Eclipse fans and have been using it for many years for everything (PHP/symfony, Java, XUL, HTML) and have even contributed plugins but we decided to evaluate NetBeans to see if it gives any extra features that might help/speed up development for our forth coming Java EE project.
Technologies we are going to use in our application are:

Preferred IDE requirements:

  • CVS integration
  • Integration with GlassFish - so that we don’t have to leave the IDE to deploy etc
  • Should support debugging of web application
  • Support for profiling
  • XML/JSP editor
  • Context sensitive help and auto completion for tags

We are comparing
NetBeans 6 Beta 1 and Eclipse 3.3 Java EE

Creating a new web project is pretty straight forward. Both IDEs create more or less same directory structure only difference being the location where Java source files are stored. Eclipse keeps them under src where as NetBeans keeps them under src/java.
Next thing I wanted to do was import (share) my project to CVS. Found it more user friendly in Eclipse although NetBeans was equally straight forward.

JSP/XML Editor
NetBeans editor is lot more advance and friendly.
Editing Web.xml in Eclipse
Editing web.xml in NetBeans

Other differences
- In Netbeans you don’t have to click on ‘fast views’ just mouse over brings the window.

- Can’t easily change destination of compiled class files in NetBeans. We wanted to try directory deployment feature of GlassFish so that we don’t have to create .war every time, this required us to compile and put the class files in WEB-INF/class folder. This setting is pretty straight forward in Eclipse whereas you have to change projects.properties file in NetBeans. (Or it was not easy to find how to change it via UI)

- One of the biggest inconveniences was not having auto import while writing Java Code. Eclipse will auto import a class if you use it (Ctrl+space) but in NetBeans you have to manually add imports. There is fix imports also but thats an extra step.

- Eclipse UI in general is more user friendly. As an example ‘output console’ had a title bar and then some tabs. Each of these tabs are (or at least look) like individual windows with separate x (close) buttons. Its very natural to double click on the title to maximize it, hence you would try to double click on title ‘GlassFish v2′ but it will not do anything. You will have to double click on the bar above it ‘Output’. This is understandable but not ‘really’ as expected. On the other hand eclipse is pretty straight forward.
NetBeans console windowEclipse console window

- Eclipse kept on crashing (giving out of memory error) on my colleague’s laptop which has 1GB RAM, this happens when he tries to run GlassFish from Eclipse. Trying to run GF outside of Eclipse doesn’t crash it. This is actually a show stopper, or he needs to upgrade RAM

- I couldn’t figure out how to auto compile and auto deploy application on NetBeans. Every time you change a class file you need to ‘build’ and ‘run’ or ‘deploy’ on the other hand Eclipse will compile and deploy automatically on save. On the other hand auto deploying can also become a problem when application size grows. But this made it very smooth on Eclipse to build/test.

We also evaluated how to create a project so that it can be opened in both the IDEs so that we can either switch or let programmers choose whatever they want. There was no ‘huge’ difference of features or one IDE helping a LOT. On the other hand as we are comfortable with Eclipse shifting on NetBeans can be counter productive as we have to learn/get used to the new IDE. We know that we will need NetBeans for debugging and profiling but development will be faster with Eclipse using directory deploy and .reload feature of GlassFish.

Visualizr - Yahoo! Open Hack Day Bangalore, India

October 9th, 2007 by Amit

Over the weekend we went to the open yahoo! hack day at Bangalore ….and what……

Hack Day - visualizr

Here are the ideas we thought of

  1. A service which will take your favorite blogs, your linked in profile or/and your favorite articles as input and create a mash-up of articles you might be interested in from Amazon or images from flickr or events from upcoming. Will also try to make a guess as to what kind of person you are.
  2. Visualizr, what we initially called as pic-story and the one we finally built.
  3. Travel Helper - Give us your travel dates and cities you are visiting and we will tell you what are the events happening during that time on those places and we will also show you interesting pictures from flickr taken in those cities so that you can decide what you want to do if you have free time.
  4. Tell us what you want to buy and we will give you all the relevant information. for e.g. items from different shopping sites, review sites, news, flickr etc
  5. Pictorial how to? Give us step by step procedure of creating or doing anything and we will return the same how with pictures to understand better.

Creating visualizr was fun and we really like the idea as it could actually be applied in lots of things like

  • Make your own cards
  • Build an ad campaign
  • With more comprehensive image access a new way of communication
  • Evolve as a How to tool? Ask 10 questions and see how Images can answer for you
  • May give a whole new way of learning difficult concepts
  • Or just brighten up your day

So what are you waiting for, go check it out visualizr

STPI incubation facility in Bangalore

September 19th, 2007 by Shyamal

We recently came to know about the incubation facility that STPI provides to new startups looking for a cost effective and worry free infrastructure. This is really suitable for new units who have not invested in their existing infrastructure and plan to get their own office (leased/owned) in a year’s time. Apart from the infrastructure they also help with HR, legal and accounting functions at extra cost.

It did not turn out suitable for us since we have already invested in our own infrastructure. But had we been aware of this facility when we started, we would have definitely opted for it.

You can contact Remali.R at STPI Bangalore for further information.

Recovering database from MySQL 4.x

August 31st, 2007 by Ved

Recently I was involved with a task to recover a database on MySQL 4.x that crashed. Below are the steps that I did to recover the database. The commands in this post are available on MySQL 4.x, if you are on MySQL version higher than this then check MySQL 5.x

1. The MYI file of the database was corrupted and I could find out that by trying to select rows from one of the tables. The error message returned for the select query - ERROR 1016 (HY000): Can’t open file: ‘TABLE.MYI’ (errno: 144).

2. Next step was to run myisamchk for which I should shut down the database first by issuing command “mysqladmin -u root shutdown” at the command prompt

3. First I tried using the –quick option on the database to rebuild the index only
/pathtomysqlexecutablefiles/myisamchk –quick /pathtodatabase/*.MYI [ to repair all the tables use wildcard (*) ], the command executed successfully, and displayed the repair information.

4. I again started mysql server using command “mysqld &”

5. Logged in to mysql prompt and selected the repaired database. To know the status of the tables after repair I executed “show table status” on the mysql prompt.

6. The results displayed error “Incorrect information in file: ‘./database/TABLE.frm” which means the frm file of the database got corrupted. Searching for the same on the web I found if we run an extended check using myisamchk may solve this problem for which I had to go to step 2.

7. There are few checks one should do if step 3 cannot help you recover the database, and after every check repeat steps 4 - 6 in the same order. You would know your table is recovered when “show table status” shows no errors, and to confirm this further you should be able to select rows from the table.

a) /pathtomysqlexecutablefiles/myisamchk –force –fast -c -i -r /pathtodatabase/*.MYI
b) /pathtomysqlexecutablefiles/myisamchk –force –fast -c -i -o /pathtodatabase/*.MYI
c) /pathtomysqlexecutablefiles/myisamchk –force –fast –update-state -i -r -e /pathtodatabase/*.MYI

if it gives error - myisamchk: error: Not enough memory for blob at 1940 (need 1890777748) (1.7GB thats wierd)
but if you think your table may be holding that much of data and your server has huge memory you may use
d) /pathtomysqlexecutablefiles/myisamchk –fast –update-state -i -o -e -O key_buffer_size=2048M -O read_buffer_size=2048M -O write_buffer_size=2048M /pathtodatabase/*.MYI
Thats giving 2 GB of memory to myisamchk for processing!
If you want to know more about visit : myisamchk Memory Usage

If the error about memory persists, it means there has been serious damage to the database. Same was the case with my database, these are the steps for recovering in such scenario:
a) Recreate a database on local MySQL server.
b) Recreate all the tables with similar schema as it is on the web server
c) Stop local MySQL server
d) Copy frm and MYD to the local computer at the same place where your newly created database exists with its (frm, MYI and, MYD) files.
e) Execute myisamchk –quick /path/to/datadir/*.MYI (One can also use REPAIR TABLE command from mysql prompt)
f) Restart MySQL Server and try selecting rows from the tables.

Free Photo Editing Softwares

August 20th, 2007 by Abhinav

Wanting a powerful and free photo editing software is a common thing. I mean when you are trying it as a hobby or for some small time fun, why would you pay $649 for Photoshop ? This is where free softwares come to your aid. Of course if you are reading this, you have looked around for them and have come across the same old lists. So which one to use ? That question is very common - and very hard to answer too. You could go for an MS Paint-Style editor with a few extra functions or yield the real power from a Photoshop-Style editor. So I am here to help you in your quest for the right editor.

  • The GIMP : You will hear this name very often. GIMP ( GNU Image Manipulation Program ) is one of the most famous names out there. GIMP started as a free open-source replacement for Photoshop and has become what it wanted to be. It is getting better with each release and the number of users is increasing rapidly. It works on Linux, Unix, Windows and Macintosh and is Multilingual. It is the idle Photoshop replacement for many people. Here are a few screenshots. If you want to ask me, this is what I recommend to anyone who is looking for a free image manipulation software/image editor.
    • GIMP on Linux
    • GIMP on Unix
    • GIMP on Windows
    • GIMP on Mac
  • GIMPshop : GIMPshop is a GIMP hack to make it feel like Photoshop. It does not sacrifice or add any features but the interface is modified to make Photoshop users feel comfortable with it. So if you are switching from Photoshop to GIMP, you should probably go for this.
  • : Another great windows-only alternative. Considered by some as “Free Photoshop”. According to their site, Paint.NET started as a undergraduate college senior design project mentored my Microsoft and was originally intended to be used as a free replacement for Microsoft Paint. It kept getting more features and became what it is now. Personally, I don’t like it much. But then that is just my opinion. You should go and try and decide for yourself. It is very powerful, but I find GIMP better. Heres a screenshot of it.
  • Pixen : Pixen is a mac-only pixel art designer. Its made for pixel artists who do their work pixel by pixel. If you are looking for big sized realistic pictures, you better avoid this one. But if you are into pixel art or want to try it, and have a mac or a mac emulator on your Windows/Linux/Unix, then you can go for it. But keep in mind that this doesn’t support layers. If you need layers, try the next one.
  • mtPaint : Another one made for pixel art. This one comes for Linux and Windows. This has support for layers so you might want to go for it if you need layers ( Pixen doesn’t support layers ). Some useful features are present in there but don’t expect something really big.
  • : This ones not really that famous. Based on GIMP and for Mac only. And its not there to replace Photoshop. A simple interface for basic home users. So you are better off with GIMP.

Employees in startups

August 18th, 2007 by Shyamal

Anuj Khurana has some great pointers of what the employees in a startup should be doing and expecting.

I specifically like points 4, 5 and 7:

  • The company’s success is your success, and vice versa
  • Always remember it’s your company
  • Self-drive and self controlled

Read the full post here

Interface translation in symfony

July 26th, 2007 by Shyamal

Symfony provides interface translation using the XLIFF standard. While using the XLIFF standard here is good, it has one pain point. The pain point becomes apparent when the need arises for changing/editing the phrases. If the phrase is used in several templates, you need to search all the templates and change there as well as in the dictionary.

For example, lets say we define a simple label like “Username” in the dictionary and in several templates. The dictionary will look like:

<?xml version="1.0" ?>
<xliff version="1.0">
  <file orginal="global" source-language="en_US"
    datatype="plaintext">
    <body>
      <trans-unit id="1">
        <source>Username</source>
        <target>ユーザー名</target>
      </trans-unit>
    </body>
  </file>
</xliff>

And in all templates that use the label “Username” we will use the following to translate it based on user’s culture:

echo __('Username');

This is good, but lets say down the line we decide to use the label “User Id” instead of “Username”. To do that we need to update all the templates and the dictionary. This becomes cumbersome if you have a large number of templates that reference this label. If you notice, the cause of the problem lies in the fact that we have used the actual text itself to identify the i18n phrase within all templates.

To get around this problem, what we did was to use a code to identify the phrase and use that in the template. And we provide a dictionary for each of the supported language. So in this case we create an English and Japanese dictionary both. But what about the source language, you would ask. Well, thats a hack: we ended up providing a non existent ISO code. Based on the comment from Dennis, we use English as the source since translation happens even if source and target languages are same.

So here is what our English and Japanese dictionary look like:

<?xml version="1.0" ?>
<xliff version="1.0">
  <file orginal="global" source-language="en_US"
    datatype="plaintext">
    <body>
      <trans-unit id="1">
        <source>LABEL_USERNAME</source>
        <target>Username</target>
      </trans-unit>
    </body>
  </file>
</xliff>

<?xml version="1.0" ?>
<xliff version="1.0">
  <file orginal="global" source-language="en_US"
    datatype="plaintext">
    <body>
      <trans-unit id="1">
        <source>LABEL_USERNAME</source>
        <target>ユーザー名</target>
      </trans-unit>
    </body>
  </file>
</xliff>

And the phrase in the template looks like:

echo __('LABEL_USERNAME')

So now if you want to change the English version of the phrase, you simply update the dictionary and no need to change the templates.

Service and product innovation - customers can help

June 29th, 2007 by Amit

A recent law suit against Dell by the attorney general of New York, says a lot about how important customer service has become. Its interesting to observe that having a good product line alone does not guarantee company’s success, rather what makes a difference is how well you are serving your customers. Innovating on how to service your customers has become as important as innovating on technology and your product.

Innovating in any field is very challenging and when it comes to customer satisfaction it becomes even more difficult because of the diverse and dynamic nature of your customer base. One way of doing this is by involving your customers in the process. Co-create. Taking help of your customers in letting you innovate on your offering, let them tell you what they need and what they don’t. Make them feel as if they belong. This instills a strong sense of loyalty. This is the focus of our new product ValueJini.

Early day impressions

June 18th, 2007 by Prashant

I started my career with GE as a trainee & left the company after 9 months very clear about ‘what’ i have to do, the only question was ‘how’. In this world there are two things related to work. first is, ‘what’ work are you doing and second, ‘how’ you are doing it. With experience the concept of ‘how’ you do work fascinates me more than ‘what’. The ‘how’ part always keeps me in unrest & busy because you always have the answer to ‘what’. But still when you talk about success then i will say, if you do not have the answer to ‘why’ you are doing the work, then nobody can save you. I am sorry if its intimidating! Because to me “The only difference between success & failure is self-realization”. Once you know yourself you will see a strong link in all the events that happen around you. Then you become a part of God’s creation working in his created world. You are here just to implement the things which he wants you to do. Know God, know yourself, everything is in you & you can manifest at will.

When I came here for the first time, after entering the meeting room & looking at the seating arrangement. I could guess that there is some relation with Japan & of course i figured out later ‘why’. Being with Techjini has been exciting & incredible, i can never believe that i will be able to create a web application in a weeks time :) . Moreover it was more so because of Shyamal who is a geek , Amit who is a punt & Ved who always keeps me busy with his fascinating stories about spirituality and @$%#$&^*(&^. Presently we are working on another exciting project hoping to launch soon in the market and we hope to make it a big success. Being here has been a great learning experience for me. I am new here but still in the few days that i have been here, i feel that as a company we seem to be doing really well.