Monday, June 17, 2013

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

I got this exception while I was trying to execute an open source application that I found from the web. I was trying to run the application from my eclipse managed tomcat 7 server. I noticed that my project's maven dependencies were not having the right jars.
This problem can be fixed by adding maven dependencies in the project's web deployment assembly.
  1. Open the project's properties (e.g., right-click on the project's name in the project explorer and select "Properties")
  2. Select "Deployment Assembly"
  3. Click the "Add..." button on the right margin
  4. Select "Java Build Path Entries" from the menu of Directive Type and click "Next"
  5. Select "Maven Dependencies" from the Java Build Path Entries menu and click "Finish".
You should see "Maven Dependencies" added to the Web Deployment Assembly definition after the following the above steps.

Friday, June 14, 2013

Wikipedia, RHEL ditches MySQL and moves to MariaDB

Prior to this Wikipedia has moved to MariaDB from MySQL recently.

According to news from the Red Hat summit which concludes in Boston on Friday, RHEL 7 will also include MongoDB.

The switch was expected to happen after Red Hat's community distribution Fedora announced earlier this year that it would be moving to MariaDB. But it will come as a major jolt to Oracle, the owner of MySQL. (openSUSE, the community distribution of SUSE, announced a switch to MariaDB at the same time as Fedora.)

Many changes in Fedora foreshadow changes in the enterprise distribution.

Once RHEL makes the switch, it will flow on to CentOS, a distribution that provides RHEL without the trademarks, hence making it free in terms of cost. CentOS is widely used by small businesses.

MySQL became Oracle's property after the company bought Sun Microsystems in 2010. There have been many complaints about its stewardship of what was once the last word in open-source database software.
MariaDB is a fork of MySQL that was begun by Ulf Michael Widenius under his new company, Monty Program. Widenius is one of the three co-founders of the original MySQL. The company was sold to Sun in 2008.

Earlier this year, Monty Program merged with SkySQL, a company set up in October 2010 by former employees of the original MySQL. Notable among SkySQL's ranks are former MySQL senior vice-president of global services, Ulf Sandberg, and adviser David Axmark, another of the three co-founders of MySQL.

Widenius and several others raised objections to Oracle's acquisition of MySQL but failed to stop the sale going through.

MySQL's first employee in Australia, Arjen Lentz, said Fedora and OpenSuSE were community driven, whereas RHEL's switch to MariaDB was a corporate decision with far-reaching implications.

"I presume there is not much love lost between Red Hat and Oracle (particularly since the "Oracle Linux" stuff started) but I'm pretty sure this move won't make Oracle any happier," said Lentz, who now runs his own consultancy, Open Query, from Queensland. "Thus it's a serious move in political terms."

He said that in practical terms, MariaDB should now get much more of a public footprint with people (people knowing about MariaDB and it being a/the replacement for MySQL), and direct acceptance both by individual users and corporates.

"Monty Program actually merged (aka was bought) by SkySQL a few months ago. SkySQL does not have significant activity in Australia and New Zealand, Open Query has. SkySQL is currently mainly active in Europe.

"So in terms of significance for AU/NZ, Open Query is definitely happy with this move, and is set to gain business for it. Which is nice in economic terms for Australia, it's not a foreign company with Australian clients."

Thursday, June 13, 2013

Type mismatch: cannot convert from null to double

Today while I was doing a code review with my team mates, I noticed some code like this
When I asked them why do you type cast "null to double", the answer they gave was I got "Type mismatch: cannot convert from null to double". There are 2 possible solutions for this,
  1. Use Double instead of double, then you may use null.
  2. Use "not a number" (NaN) like this 
submit to reddit

How to remove a plugin from eclipse

Go to Help > About Eclipse > Installation Details, select the software you no longer want and click Uninstall. (On Mac it is Eclipse > About Eclipse > Installation Details.) In older versions, you might need to Run Help > Software Updates > Manage Configuration..., select the feature of interest, and disable it with the task shown in the right window.

When a feature is disabled, all its plug-ins will be disabled also. They are still available on disk, and they can be enabled at any time in the future.

To physically remove the feature and its plug-ins, you will have to manually remove the feature from the eclipse/features directory and its plug-ins from the eclipse/plugins directory. I advise extreme caution here. Remove the wrong ones, and you may spend quite some trouble restoring your Eclipse to a stable state.

Thursday, June 6, 2013

How to use VIM editor

VIM Editor Commands
Vim is an editor to create or edit a text file. There are two modes in vim. One is the command mode and another is the insert mode.
  1. In the command mode, user can move around the file, delete text, etc.
  2. In the insert mode, user can insert text.
Changing mode from one to another
From command mode to insert mode type a/A/i/I/o/O (see details below)
From insert mode to command mode type Esc (escape key)

Some useful commands for VIM
Text Entry Commands (Used to start text entry)
  • a     Append text following current cursor position
  • A    Append text to the end of current line
  • i      Insert text before the current cursor position
  • I     Insert text at the beginning of the cursor line
  • o    Open up a new line following the current line and add text there
  • O   Open up a new line in front of the current line and add text there
The following commands are used only in the commands mode.
Cursor Movement Commands
  • h                   Moves the cursor one character to the left
  • l                    Moves the cursor one character to the right
  • k                   Moves the cursor up one line
  • j                    Moves the cursor down one line
  • nG or :n       Cursor goes to the specified (n) line (ex. 10G goes to line 10)
  • ^F (CTRl F) Forward screenful
  • ^B                Backward screenful
  • ^f                 One page forward
  • ^b                One page backward
  • ^U               Up half screenful
  • ^D               Down half screenful
  • $                  Move cursor to the end of current line
  • 0 (zero)        Move cursor to the beginning of current line
  • w                 Forward one word
  • b                  Backward one word
Exit Commands
  • :wq  Write file to disk and quit the editor
  • :q!   Quit (no warning)
  • :q     Quit (a warning is printed if a modified file has not been saved)
  • ZZ   Save workspace and quit the editor (same as :wq)
Text Deletion Commands
  • x       Delete character
  • dw    Delete word from cursor on
  • db     Delete word backward
  • dd     Delete line
  • d$     Delete to end of line
  • d^     (d caret, not CTRL d) Delete to beginning of line
  • Yank (has most of the options of delete)-- VI's copy commmand
  • yy      yank current line
  • y$      yank to end of current line from cursor
  • yw     yank from cursor to end of current word
  • 5yy    yank, for example, 5 lines
  • Paste (used after delete or yank to recover lines.)
  • p       paste below cursor
  • P       paste above cursor
  • "2p   paste from buffer 2 (there are 9)
  • u       Undo last change
  • U      Restore line
  • J       Join next line down to the end of the current line
File Manipulation Commands
  • :w    Write workspace to original file
  • :w    file Write workspace to named file
  • :e     file Start editing a new file
  • :r     file Read contents of a file to the workspace
  • To create a page break, while in the insert mode, press the CTRL key and l. ^L will appear in your text and will cause the printer to start A new page.
Other Useful Commands
Most commands can be repeated n times by typing a number, n, before the command. For example 10dd means delete 10 lines.
  • .      Repeat last command
  • cw   Change current word to a new word
  • r      Replace one character at the cursor position
  • R     Begin overstrike or replace mode – use ESC key to exit
  • :/      pattern Search forward for the pattern
  • :?     pattern Search backward for the pattern

Examples:
Opening a New File
  1. type vim filename (create a file named filename)
  2. type i ( switch to insert mode)
  3. enter text (enter your Ada program)
  4. hit Esc key (switch back to command mode)
  5. type :wq (write file and exit vim)
Editing the Existing File
  1. type vim filename (edit the existing file named filename)
  2. move around the file using h/j/k/l key or any appropriate command
  3. edit required text (replace or delete or insert)
  4. hit Esc key (exit from insert mode if you insert or replace text)
  5. type :wq

Wednesday, June 5, 2013

How to exit from an unix manual page

Though the answer is simple, I have struggled a bit to get out of the man page. Thought this could help for unix beginners like me.

"man" command is very useful to read the manual of any commands that you use from terminal on a linux/mac machines.

From your terminal "man command-name" takes you to the manual page.

In order to navigate in the pan page use "up" or "down" arrow keys for navigation. In certain cases you may have to use enter key.

To get out of the man page simply type "q", this will take you to the command prompt from open terminal.

Ex: man ssh, man chmod, man ls

How to create a new git local branch and push to repository (remote/origin)

From your terminal using commands
Check your git version with the following command,
git --version
if you have git version equal or greater than 1.7.0, you should be able to do with the following commands.
git checkout -b newbranch

git push -u origin newbranch
The first command creates a new branch from your current local branch. In order find what's your current branch use the command "git branch -a". It will list all available branches, the current branch will be preceded with a *.
The "-u" option is available only from git 1.7.0. It refers to "upstream" to where you want to push to or pull from.

From eclipse
Right click on your eclipse project Team -> Switch to -> New branch.

Create branch from eclipse

Give your new branch name in the following dialog and then click Finish. This will create a new branch from your current working branch.

Make all your changes to the new branch, to push the newly created branch right click Team -> Commit & Push (EGit2.x versions).

From github
The simplest way to create a new branch is from Github. If you have push access to the repository, start typing the new branch name in the search box of switch branches/tags. This box will appear once you click on the down arrow near branch. Once you complete typing the branch name, you will see an option to create new branch with the name provided. Click on it, you are done.

Create branch from github

submit to reddit