Saturday, February 7, 2009

Steps to install Bazaar with Eclipse and Lauchpad on Windows

Following are the steps to install Bazaar:
  1. Bazaar needs Python 2.5 or Python 2.4 for working. Here I will be using Python2.5. Install Python 2.5 from http://www.python.org/download/releases/2.5.4/
  2. I assume that you have used default locations for installing Python. By default it gets installed at C:\Python25
  3. Modify the PATH environment variable to include C:\Python25. You can do this by going to Control Panel->System->Advance System Settings->Click on Environment Variables->Find "PATH" in the System Variable Section->Select Path->click Edit->append ; C:\Python25 to the existing string.(Don't forget the ';' separator)
  4. Download the latest STABLE version of Bazaar for Windows from https://launchpad.net/bzr/+download. Select the python2.5 installer from the list.
  5. After downloading the python2.5 installer for bazaar, go ahead and run the setup.
  6. By default the bazaar script(bzr.bat) gets installed at C:\Python25\Scripts
  7. Add C:\Python25\Scripts to the "PATH" system variable. Refer step 3 for editing the "Path" variable
  8. Open command prompt and type "bzr --version". If you get the version of bazaar then you can assure your self that bazaar has been  successfully installed on your machine, else you should check the steps once again.
  9. Now, before I go ahead with installing the eclipse puglin for bazaar, we will need to install a plugins that BzrEclipse uses. So, lets install the bzr-xmloutput plugin from https://launchpad.net/bzr-xmloutput/+download. Make sure you download an exe file for windows.
  10. Follow the steps for eclipse installation from http://bazaar-vcs.org/BzrEclipse/Installation
  11. NOTE: the executable for bzr is present at C:\Python25\Scripts\bzr.bat. This is the path you should browse to when the eclipse plugin asks you for the bazaar executable. The userid/email is the email address for your launchpad account.
Now, the next step is to connect with Launchpad:
  1. Create a new project in Eclipse. 
  2. Right click the project folder in the package explorer->Team->Share Project->Select "Bazaar" from the repository type->Click Next->Finish
  3. To pull an existing project from launchpad, right click the project folder->Team->Pull from->type in the pull url(This is the launchpad url for your project.For me it was lp:c322blackberry)
  4. You might notice that, the pull operation moves the existing src and bin directory. This is because eclipse created these directories and they were not in the branch that we pulled from launchpad. To avoid this you can delete the src and bin folders that eclipse creates before doing the pull operation.
  5. If the pull operation works, you have successfully installed the BzrEclipse plugin for Eclipse
Pushing a branch from Eclipse:

Pushing a branch to launch pad is kinda tricky because you have setup the ssh keys. To setup SSH keys you will need to install three programs viz: plink, puttykeygen and pageant

  1. So, the first step is to download and install plink, puttygen and pageant from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
  2. Start Puttygen, generate a public and private key pair. PuttyGen is a very cool program, you will have to do some random movement with mouse to generate the key pairs.
  3. Once you have generated the key pairs, save them on your hard drive.
  4. Copy the ENTIRE public key. Now go to your profile on launchpad->click change details->Click SSH Keys->Paste it in add SSH key section->Click "Import Public Key"
  5. You will get a confirmation message that your public key is added.
  6. Now, open Pageant and load your private key. (When you click on the exe file of pageant it will create a icon(a computer with hat) in your task bar. Click on that icon to open pageant)
  7. Now, you have loaded your private key.
  8. For Bazaar to use your private key, you will need to set the BZR_SSH environmental variable to plink.
  9. So, goto Control Panel->System->Advanced Settings->Environment Variables
  10. In the System Variable section click add->add new environment variable "BZR_SSH"-> set its value to "plink"
  11. For BZR_SSH to find plink, you should either copy plink.exe file to C:\Windows or add its location to the "PATH" environment variable.
  12. Now, create a new project in eclipse, make it a branch, commit it, then try to push it to a new branch to your lauchpad account.
  13. You should be able to successfully push the branch.

Thursday, January 29, 2009

Hello World Spring Program does not work

Hi,

If you just started to learn spring framework with the traditional approach by writing a helloworld program, then you might come across this:

BeanFactory factory; factory = new XmlBeanFactory(new InputStreamResource(new FileInputStream("hello.xml")));

here it shows the following error after run:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.beans.factory.support.Abstract BeanFactory.(AbstractBeanFactory.java:99)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.(AbstractAutowire CapableBeanFactory.java:97)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.(AbstractAutowire CapableBeanFactory.java:106)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.(DefaultListableBeanFacto ry.java:87)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.(XmlBeanFactory.java:67)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.(XmlBeanFactory.java:56)
at HelloApp.main(HelloApp.java:25)


This happens if you don't have commons-logging.jar in your classpath. You can download commons-logging.jar library from

http://commons.apache.org/downloads/download_logging.cgi