Thursday, 16 May 2013

Create a simple JSR 286 Portlet using Maven, Eclipse IDE, MySql - Part 1

The Portlet we are going to create can be run on any Portal Server. I have used Liferay Community Edition since its available for free.

The tools we are going to use are:

1. Java V 1.5 and above.
2. Maven: It makes life so much easier.
3. Eclipse IDE
4. MySQL database
5. Liferay Community Edition bundled with Tomcat: Latest version is available at

Basic Setup:

  1. Install Java JDK 7: the JAVA_HOME environment variable.Update the path environment variable. Add ;%JAVA_HOME%\bin; at the end.
  2. Download Apache Maven:
  3. Unzip it at a convenient location. Lets say C:\development\maven
  4. Add another Environment variable MAVEN_HOME with the above location.
  5. Again update path environment variable. Add ;%MAVEN_HOME%\bin; at the end.
  6. Go to windows console using cmd. Type mvn -version to check if it works.
  7. Next download Eclipse. I usually use Eclipse IDE for Java EE Developers. URL:
  8. Once download is complete extract eclipse at a convenient location like C:\development\eclipse
  9. Now install Maven plugin for eclipse. Just go to help->install new software, in eclipse.
  10. Use the following update site:
  11. Now from eclipse navigate to window->preferences->maven->installations and add the maven location you just extracted.
Portal Server: I prefer Liferay Portal's Community edition since its free and has lot of features.

To download Liferay go to the following website and download there tomcat bundle.
Liferay uses hypersonic database by default.

I prefer MySQL database since its free and pretty good. You will need MySQL server and workbench. Both can be installed from the MySQL website.

When you will start Liferay for the first time it will ask for database configuration. You can either configure database then or you can place a properties file under the root directory where you extracted the bundle.

Liferay creates a properties file by default when you configure database at startup. If it doesn't you can create a with following content:


If you are working with the latest version of MySQL and Liferay bundle you might see database related exceptions on startup.
To resolve these just download mysql-connector-java-5.1.25 and place it in tomcat/lib/ext folder.

Next we will look at how to create our first Portlet.

1 comment:

  1. Wow, marvelous blog format! How long have you been blogging for? you make running a blog glance easy. The total glance of your website is excellent, let alone the content material!
    Create a MySQL database.