Eclipse, web projects, building for tc server on Eclipse and for regular Tomcat server
I tend to forget the configuration required for building a Spring based web project for tc server on Eclipse and for regular Tomcat server because I don't do it frequently.

Here are the important points:
- Download Maven (m2eclipse), pivotal tc server, wtp (Jave EE Developer Tools, Java Web Developer Tools,
Web Developer Tools, XML Editors and Tools, XSL Developer Tools, m2e-wtp Maven Integration for WTP),
Spring Tool Suite (necessary ones, you can exclude Dashboard, tc server (previously installed), etc)

- Open Servers view (Views->Servers) and add the local Tomcat.

- If you import an existing Spring MVC Maven project, it may show an error as "HttpServletRequest cannot be resolved to a type" for jsp files.
 This is because the runtime for the web project is not set to the Tomcat installation where HttpServletRequest resides.
 Fix: Project Properties -> Targeted Runtimes -> select the installed Tomcat server.

- To produce the war file:
    You should add the the servlet-api dependency to pom.xml.
    The scope should be provided. Add it from the tomcat group, not maven's own.

- To be able to use Apache Tomcat 8, change catalina.jar:
    org/apache/catalina/util/ file
 and set installed facet to at least 2.5 in .settings/org.eclipse.wst.common.project.facet.core.xml.
 You can set to 3.0 for example.

    * Spring throws an exception when async support is not mentioned in web.xml (used in WebSocket apps):    workspace, an exception is thrown when the websocket using page is requested from the browser:
    "Async support must be enabled on a servlet and for all filters".

    To overcome, add "true" to all servlets and filters. web.xml version
    must be 3.0. It is explained here: -> Servlet 3 Async Config

- Folders after .war is generated:

   Folder and files after maven install
- Folders before .war is generated. It runs on tc server:
Folder and files for tc server

How to convert a project to a Maven (m2eclipse) Project
If an existing project is a Maven project, it should be converted to a m2eclipse project to be able to use m2eclipse utilities. To do this, right-click on the project --> Configure --> Convert to Maven Project.

Only after this, Maven utilities (build, clean, install, etc) are displayed when right-clicked --> Run As is selected.

A nice blog post about consumption provoking lifestyle

Installing python modules to Windows 8 (64-bit)
Windows installers for modules may need a registry entry of python. Python installer does not create it automatically. Create a registry entry as explained in this site:

Even if my python version was for 64-bit, I changed the registry as it is changed for 32-bit version, i.e. not under Wow6432Node. It worked for numpy.

I am copying it in case link dies:
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
# written by Joakim Loew for Secret Labs AB / PythonWare
# source:
# modified by Valentine Gogichashvili as described in
import sys
from _winreg import *
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
def RegisterPy():
  reg = OpenKey(HKEY_CURRENT_USER, regpath)
except EnvironmentError as e:
      reg = CreateKey(HKEY_CURRENT_USER, regpath)
      SetValue(reg, installkey, REG_SZ, installpath)
      SetValue(reg, pythonkey, REG_SZ, pythonpath)
      print "*** Unable to register!"
  print "--- Python", version, "is now registered!"
if (QueryValue(reg, installkey) == installpath and
  QueryValue(reg, pythonkey) == pythonpath):
  print "=== Python", version, "is already registered!"
print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
or just inject the following REG file into your registry if you are using python 2.6 installed in C:\Python26 directory

Windows Registry Editor Version 5.00

I changed the version to my python version and used the second method.

Injecting registry entry is simple. Just save the lines to a text file with .reg extension and double-click it.

The worst mistake in the history of the human race

which command equivalent in Windows
WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid

Open C:\ProcessList.txt. It should contain the command-line parameters etc.

Serendipity vs safety
A good article about loss of chance element in life by Frank Bruni of NY Times:

Opening google maps in AVD and a few basic commands
First, we need to have an AVD created with Google APIs.

It is done from Android SDK Manager.Install an SDK that suits with Google APIs.

You can either create a new AVD with our new SDK or edit an existing one and set the SDK to the version (target) to Google APIs - API Level .

Then you may need to install the files and

I installed thos apks to an AVD which did not have Google APIs. The Google Maps app did not appear. Later, I changed the target as explained above. Google Maps appeared after the change. So, I am not sure whether Maps is installed by default.

Install command is: adb install

Here is a tutorial for developing an app that uses maps:

Not related to the issue above, I wanted give some basic commands to work with AVDs.

android list targets
monitor: opens DDMS tool
emulator -avd htc_desire_s (or “emulator -avd -partition-size 500 -no-audio -no-boot-anim)
adb -s shell: serial number is the code given when "adb devices" is run. For this to run the AVD, that AVD should be started using emulator command.
adb devices: shows the serial numbers of the currently running emulators or connected real android devices.

HTTP request using a proxy
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider.setCredentials(new AuthScope("", 8080), new UserPasswordCredentials("username", "password"));

HttpRequestBase method = new HttpGet(url);
method.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, 8080);

HttpResponse response = httpClient.executeMethod(method);
Tags: ,

Spring JSR-303 bean validation - 2
If you want to do the validation manually, e.g. when you are using Apache CXF for REST service instead of Spring MVC, you can still validate the incoming object.

Use an org.springframework.validation.Validator and org.springframework.validation.BeanPropertyBindingResult.

public String getResponse(ContextQuery query) {
// 2nd parameter is just the name of the valiable
BeanPropertyBindingResult bindRes = new BeanPropertyBindingResult(query, "query");
validator.validate(query, bindRes);

if (bindRes.hasErrors()) {
//handle errors as explained in the previous post.

You are viewing sevgiinsani