Solr vs Lucene

In this post, we are not trying to compare Solr and Lucene, as both are not different technologies, but we are trying to identify when to use which. I would recommend that in 90% of the cases, or even more, Solr would be the preferred choice, as it’s nothing Serverization of Lucene. Below are the list of additional features which solr provides, on top of Lucene:

  • – Processing request over http
  • – Caching mechanism
  • – Admin interface
  • – Configuration in xm file, with notion of fieldType
  • – DisMax query
  • – Spell check & suggest
  • – More like this
  • – Distributed & cloud features
  • – DataImportHandler & other handlers for extracting data
Above features makes it the preferred choice. Now comes the question when should you use Lucene. It most of the cases you would not. But if the memory available is limited like in cases of mobile devices or you need to write lot of low level code, tuning/adding your own logic, Lucene would be your choice.

Java Best Practices

When creating a Java application, the following best practices should be considered:

  • Program to an interface, not an implementation.
  • A class should have only one reason to change.
  • Identify the code that vary and separate it from the code that remains the same.
  • No principle is a law. Principles just provide guidance. Hence should be used when and where they are helpful.
  • All designs have tradeoffs like abstraction vs speed, time vs space. Hence, all factors should be taken into account before applying them.
  • Favor composition over inheritance.
  • Classes should be open for extension but closed for modification.
  • Depend on abstraction. Do not depend on concretion.
  • Only talk to your friend.

States of Functional Design Document

Following are the states of Functional Design Document:

  1. Draft
  2. In Review
  3. Final
  4. Approved

JCP Specification Steps

The following are the essential JCP steps to become a final specification & potentially become part of the java platform:

  1. Initiation
  2. Early Draft Review
  3. Public Draft Review
  4. Maintainence

Tomcat Error on deploy / undeploy on an application

SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base <application> does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(
at org.apache.catalina.core.StandardContext.resourcesStart(
at org.apache.catalina.core.StandardContext.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase.addChild(
at org.apache.catalina.core.StandardHost.addChild(

Tomcat throws this error when the <application> path is hard-coded/set in the context but it doesn’t find the corresponding directory.

One possible reason can be that the application/war has been removed from the webapps directory but the context for this exist. Try removing the context from the conf at location {CATALINA_HOME}/conf/{Engine}/{Host}/<applicationname>.xml

You have an application called testapplication.war in webapps and now you replaced it with tryapp.war. This may lead to
above mentioned error.

1. Remove the {CATALINA_HOME}/conf/Catalina/localhost/testapplication.xml
2. Enjoy šŸ™‚


Build Mavan project without TestCase

If you want to build a maven project without running the test cases, it can be done in several ways:

  1. If the build is being invoked from terminal, build needs to be done with additional argument:
    • mvn -Dmaven.test.skip=true
  2. If the build is being done from Netbeans IDE, below is the step:
    1. Right click on the maven project and select Custom -> Goals
    2. Type Install in the Goals field
    3. Select the check box ‘Skip Tests’
    4. If you want to build project even in future with testcases, select the check box ‘Remember as’ and give a name
    5. Click Ok

      Netbeans maven build without test cases

      Snapshot for maven build without testcases in Netbeans

If you want to start the Netbeans Profiler without running the testcases, you need to add the following tag in pom.xml within <profiles><profile><profile><profiles> tag:


Unix nohup &

nohup – No Hangup

It is a POSIX command to ignore the hangup signal. This enables the command to keep running ever after the terminal has been logged out.

So if you want to run a deamon process, nohup is the command for you. By default the nohup terminal output goes to a file called nohup.out in the same directory.
term$ nohup
nohup: ignoring input and appending output to `nohup.out’
term$ ls -lrt
total 4
-rwxr-xr-x 1 dsahi dsahi 306 2011-04-19 11:56
-rw——- 1 dsahi dsahiĀ Ā  0 2011-04-25 10:35 nohup.out

If you want the output to be redirected to some other file, you need to use the redirection operator.

term$ nohup > test.log
nohup: ignoring input and appending output to `nohup.out’
term$ ls -lrt
total 4
-rwxr-xr-x 1 dsahi dsahi 306 2011-04-19 11:56
-rw——- 1 dsahi dsahiĀ Ā  0 2011-04-25 10:35 test.log

nohup is generally used in combination with &, which makes the process to run in background. It’s something like ‘Don’t wait for me to complete’.

term$ nohup &term$ exit

Instantly after triggering the command, you will see the terminal prompt available for you to type in the next command.