5/20/2015

How to prevent logging JARs from being copied to your portlet´s WEB-INF/lib folder

Quick Tipp for all of you who have their logging implementation in their LIB/EXT directory. This is how you prevent liferay from auto-deploying log4j and apache commons logging each time you deploy a portlet:

Add this to your portal-ext.properties file:


auto.deploy.copy.log4j=false
auto.deploy.copy.commons.logging=false

Developing Liferay with Oracle

If you´re working on a mac, like I do, and you´re working on a lot of customer projects then you might run into the situation where you have to use an Oracle database instead of the standard MySql one. This blog post is about how to download, configure, connect and developer with Oracle and liferay.

Getting the VM

You can download and install an Oracle VM for your mac computer at no cost. Just download it from this page : https://tech.lds.org/wiki/Oracle_VM  (Direct download link: Download the Oracle VM Appliance Zip ). I have to thank those guys at LDSTech - they have a created an easy to use and understandable instruction set to get Oracle running on macintosh. I will copy most of their stuff here so that it doesn´t get lost in case they modify their page.

So please download the VM from the link above, and while you´re doing so, please also download VirtualBox. You will need it to run the vm image. You can download it here: Download and install VirtualBox

Unzip the vm file and import it into VirtualBox. Start the VM and it will begin configuring itself. Just go and get yourself a cup of coffee: This might take a while. Once it is done, the machine will shutdown itself. Don´t shut it down manually, let it finish.

Once the machine is ready, you need to configure the ports in order to forward all calls to the oracle installation to the vm. Select the network settings of your virtual machine, leave the "Attached to" value as NAT and expand the Advanced options, then click Port Forwarding and add the following rules:
  • Rule 1: Host Port = 1521, Guest Port = 1521
  • Rule 2: Host Port = 9999, Guest Port = 8080

This way you make sure, the web administration console is accessible even though you have a running liferay server on your computer. Restart the VM and you should be able to access the oracle xe admin console using this url : http://localhost:9999/apex and then see the following:


To administer your Oracle XE instance using the web admin gui, the username is SYSTEM and the password is oracle. Log in and have fun !

Preventing a common error in a complex liferay environment

Before we actually connect liferay to oracle, we need to prevent one common error that happens, when you have a complex liferay installation: maximum number of sessions exceeded. When you run liferay with oracle you might see one of these error messages (together with a stacktrace) in your concole:


  • ORA-00018: maximum number of sessions exceeded
  • ORA-00020: maximum number of processes (%s)
  • TNS Name Not Found -


This error of umber of concurrent sessions and processes is a common problem with oracle vanilla installations and we can fix it pretty easily. First, we need to enter the administration console of our oracle xe installation.If you want to log in to your oracle installation using the command line you you need to do so from the virtual machine. No problem: It is a fully functional linux installation :) So login into your linux VM using ldstech / ldstech.





Next, we need to run sqlplus to let us into the actual database. Enter the following: sqlplus system@XE as sysdba .

To set the values to a proper amount, enter the following :


alter system set sessions=300 scope=spfile;
alter system set processes=300 scope=spfile;


After that just restart your VM and the changes should have taken effect.


Using Oracle with liferay


Now that you have oracle up and running, it is time to connect liferay to use it. Create an oracle database (aka create an oracle user) named "lportal", assign all neccessary rights and startup liferay. Upon your first start liferay will ask you to choose a database provider. We will choose Oracle and enter the following data:

jdbc.default.username=lportal
jdbc.default.password=lportal
jdbc.default.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.default.url=jdbc:oracle:thin:@localhost:1521:xe



Using SQL Developer


My standard Tool to connect to an oracle XE database is the Oracle SQL developer. You can download it here: SQL Developer Download



Install it, start it up and then create a new connection. This Screenshot shows you, what to enter into the various configuration fields and after that you should be good:






If you have any questions, feel free to leave a comment.

Liferay Multi Tenancy

Liferay offers Multi Tenancy Features using portal instances. You can create several portal instances in your liferay 6.2 control panel by going to

Configuration / Portal Instances .

Click on "Add" and fill out the following form:

A fine (german) menu to add portal instances



WEB-ID is the identification String for this instance. Kind of a unique user generated ID.

Virtual Host is the most important entry. Since liferay doesn´t allow you to switch instances from a dropdown menu this is the URL that will be used to determine which liferay instance to show to you. So if you want your users to access your portal using the URL "http://www.findsite.com" then please enter this URL in the Virtual Host field. Once a user is transferred to your page from your original home page URL he will automatically be transferred to this instance. As far as I know there is no other way to access the other instances without this mechanism.
If you don´t have such a URL ready you need to modify your hosts file.

Maildomain This is used for sending out Emails and logging you in the first time. Example: mymaildomain.com

Max Users: Simply the maximum amount of users in your portal.


So you know how to connect to the server (using your hosts file on your computer) but how do you log in ? The initial login is test@mymaildomain.com / test.