Lucene An SPI class of type org.apache.lucene.codecs.Codec with name does not exist

if you are getting this error

An SPI class of type org.apache.lucene.codecs.Codec with name ‘Lucene54’ does not exist

Add Folders

If maven based project then add META-IN/services folders in src/main/resource

else just create META-IN/services folders inside classpath

And File

1- org.apache.lucene.codecs.Codec inside META-INF/services/

with following text inside


It works. The key thing is to remember the version no of lucene jar should match org.apache.lucene.codecs.lucene54.Lucene54Codec text.  I m using lucene 5.4 so lucene54.Lucene54Code.





Thymeleaf Whitelabel Error Page – Convert html to thymeleaf template

Although , browsers are very forgiving in nature and ignore incomplete tags, but Thymeleaf blow out if it finds document to be not well structured xml document, and if we donot follow these rules, thymeleaf gonna be very angry with us, so lets understand those tweaks.


XML Namespace

Add xml namespace for thymeleaf

<html lang="en"> to <html lang="en" xmlns:th="">

Meta Tag

The element type “meta” must be terminated by the matching end-tag “</meta>”

<meta charset="utf-8" > to <meta charset="utf-8" />

Image Tag

Although browser ignores these, we have to do it for thymeleaf.

<img src='//' > to <img src='//' />


Link Tag

<link href='//' rel="stylesheet" > 
<link href='//' rel="stylesheet"  />


Error : The content of elements must consist of well-formed character data or markup.

< script type="text/javascript"  >
 window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
< / script >
You need to add CDATA tags for the script like this
< script type="text/javascript"  >
     window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
</ script >

Eclipse Thymeleaf Intellisense Installation

In Eclipse, go to Help >> Install New Software… then either use the update site URL, or download a ZIP archive of the plugin from SourceForge:

Thymeleaf Hello World – day 1 – Project Structure

Developing application using Spring boot and Thymeleaf is simpler and quick, if you follow these convention. Thymeleaf requires a specific project structure which helps to render views and refer items without getting into error.

Since we are using Spring Boot, because we’ve included the dependency springbootstarterthymeleaf in our Maven POM for the project, so Spring Boot will do some things automatically for us.


By default, Spring Boot configures the Thymeleaf template engine to read template files from src/main/resources/templates .

Effectively, you as the developer just need to start making Thymeleaf templates and dropping them into  src/main/resources/templates.

Static Resources

It includes libraries and their respective javascript (*.js) and stylesheets (*.css) files to be placed inside src/main/resources/static


Project Structure/Convention

  • Messages to placed inside src/main/resources/messages into the
  • It requires static web content to be placed inside src/main/resources/static (this will be the root directory for your web application for static content like images, CSS and JavaScript files)
  • Most importantly templates must go into src/main/resources/templates and if required, subdirectories there.

Be clean on configuration

  • Use src/main/resources/ as few as possible
  • Use src/main/resources/applicationContext.xml as few as possible
  • Try to use annotation-based configuration as much as possible

All those points are very important, if you don’t follow them, you will get into trouble when you try to run your application standalone and not from your IDE!

Reference :


Learn Recursion – Advantages of Tail Recursion (Day 3)

The tail recursive functions considered better than non tail recursive functions as tail-recursion can be optimized by compiler. The idea used by compilers to optimize tail-recursive functions is simple, since the recursive call is the last statement, there is nothing left to do in the current function, so saving the current function’s stack frame is of no use.

Recursion and Stack Frame

Stack : Variable

Global or Static Variables are stored here.


Learn Recursion – Day 1

Lets review some recursion types.

  • Tail Recursion: A call is tail-recursive if nothing has to be done after the call returns. I.e. when the call returns, the returned value is immediately returned from the calling function. More simply, tail recursion is when the recursive call is the last statement in the function. See Tail Recursion.
  • Head Recursion: A call is head-recursive when the first statement of the function is the recursive call.
  • Middle or Multi Recursion: A call is mid-recursive when the recursive call occurs in the middle of the function. I.e. there are other statements before and after the recursive call. If one or more of these statements is another recursive call, then the function is multi-recursive. There is no essential difference between Head Recursion, Middle Recursion and Multi Recursion from the standpoint of efficiency and algorithm theory.
  • Mutual Recursion: Function X and Y are called mutually-recursive if function X calls function Y and function Y in turn calls function X. This is also called indirect recursion because the recursion occurs in two steps instead of directly. See Mutual Recursion.

MAVEN – How to install Jar / War in maven repository

Question : How to install JAR in maven repository.

mvn install:install-file -DgroupId=com.companyname -DartifactId=libraryOrJARName \
     -Dversion= -Dpackaging=jar -Dfile=jarproject.jar -DgeneratePom=true
Question : How to install WAR in maven repository.
mvn install:install-file -DgroupId=com.companyname -DartifactId=WARName \
     -Dversion= -Dpackaging=war -Dfile=webproject.war -DgeneratePom=true