Migrating vom iReport to Jasper Studio (1): Fields Provider

We recently switched from iReport to Jasper Studio and this is a very brief summary of what we had to do to make everything work in Jasper Studio as it did in iReport.

The first Part is about the Fields Provider.

Fields Provider are a thing of the past. You need to use 
JRDataSourceProviders if you want to have the same features in Jasper Studio. Create a class as a subclass of JRDataSourceProvider. Implement the method "getFields". This is the very same method you´ve used in iReport. So you can pretty easily take your old code and put it there.

Afetr you´ve implemented your DataSourceProvider, put it in a JAR file and create a Data Adapter. Those Adapters are used in Jasper Studio to allow you to query your fields. Either create a data adapter using a generator (it´s just XML ...) or create it in Jasper Studio (by selecting JRDataSourceProvider). That´s it!

I will post a longer entry once I have more time.

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


How to read URL Parameters in Freemarker

I found an interesting snippet today while I was searching for a way to read URL Parameters in Freemarker Asset Publisher Templates. What I wanted to do was to configure the way my Asset Publisher Advanced Display Template behaves. I am creating URLs like this : http://www.my-server.com?param=value and I wanted to read them in an Asset Publisher freemarker template.
This is how you do it :

<#assign context = staticUtil["com.liferay.portal.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign httpServletRequest = context.getRequest()>
<#assign parameter = (httpServletRequest.getParameter('param')?html)!''>

The interesting part is the !' ' at the end which prevents Exceptions from popping up when there is no URL parameter. 


JIRA Development: Getting Priorities by Name

If you want to set the priority of an issue in JIRA programmatically then you need the priorityID. This is how you get it when you only have the name (Major, Minor etc.).
String priorityID = null;
PriorityManager priorityManager = getPriorityManager();
List priorities = priorityManager.getPriorities();
for (Iterator iterator = priorities.iterator();iterator.hasNext();) {
  Priority priority = (Priority) iterator.next();
  String id = priority.getId();
  String name = priority.getName();
  if (name.equalsIgnoreCase(priorityName)){
    priorityID  = id;
Once you have the prriorityID you can set it like that :
IssueInputParameters inputParameters = getIssueService().newIssueInputParameters();
inputParameters.setPriorityId(priorityID );

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


JIRA Development: Setting Options in Custom Fields

Everyone I know uses JIRA, including me. Admit it, you´re using JIRA, too ;) 
I am always surprised when I find people using other Issue Tracking Software.
I am not only using JIRA, I am developing for it and with the great JIRA plugins SDK you can easiliy create and extend every possible plugin in JIRA. This is why I will post some tipps and snippets in the next days.

I am going to start with a problem that many of you will run into: How do you set am Option in a multi or single select custom field ? Example: Set the select field to select the "Option B" value. That´s how you do it:

public static Option getCustomFieldOption(String name, Issue issue, String ovalue){
  CustomField field= customFieldManager.getCustomFieldObjectByName(name);
  FieldConfig relevantConfig = field.getRelevantConfig(issue);
  Options options = optionsManager.getOptions(relevantConfig);
  Iterator iterator = options.iterator();

  while (iterator.hasNext()) {
    Option option = (Option) iterator.next();
    String value = option.getValue();
    if (value.equalsIgnoreCase(ovalue)){
      return option;
  return null;

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


How to get the jSessionId from a velocity template in liferay

Just a quick tip because I´ve been searching for it a while.

When you´re creating inter - portal links and your portal is using jsessionids to identify the logged in user you might run into the situation where a link created in a web content (JournalArticle Link To Page) doesn´t contain the jsessionid and everyone who follows that link is no longer logged in.

What you need to do in this situation is to attach the jsession id to your link. This is how you do it. You can use the "Link To Page" Structure Entity that liferay is giving you and then simply add the portlet session id:

<a href="${link.getUrl()};jsessionid=$request.get('portlet-session-id')"> 


$theme.runtime("145") after liferay crash

If your liferay server crashed and after the crash your dockbar disappeared and you see this error message ...

and this repeating over and over again in your log file ...

at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:136)
at org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:320)
at org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:357)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:467)
at org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1779)
at org.apache.jasper.compiler.Parser.parse(Parser.java:135)

...I might have the solution for you. The solution is to replace the file view_user_account.portal.jspf in ROOT/html/portlet/dockbar/ with a fresh version from your zip. Do this and restart the server and you should be good.


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:


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:


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.