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. 


Liferay 7 : Elasticsearch vs. SOLR

Liferay 7 will switch from lucene to elasticsearch as the standard search provider. But what is elasticsearch and why is it a good idea to have it in your liferay installation ? And where´s the difference to SOLR, which is already a good alternative and can be integrated into Liferay pretty easily ?
Let´s take a look at the google search queries from the last years to see how many people care for which search technology.

As you can see, elasticsearch surpassed SOLR in the last year. Question is: why ? Let´s talk a little about both technologies to see if there is an actual technological explanation for what we see here. Note: There are so many ways to compare both technologies that there is an own site just for that. If you want to dig down really deep I would suggest taking a look here: http://solr-vs-elasticsearch.com/

This video is a nice introduction to SOLR:

And this one is a good one about elasticsearch:

Consider having more requirements to your liferay search then just providing a search field. Consider specifying how your search behaves, which data types will be indexed and consider a clustered, fail-save environment with a lot of data.

If you have a lot of data, that you could also group into several indexes then you need "shards". A shard is an index of its own that can be accessed by your search provider. SOLR and elasticsearch allow you to define shards and also allow you to define schemas for each shard. Using shards you can define a shard for the users, another one for documents and a third one for car information. All shards can have different attributes that you can search for. Those attributes will be defined either out of the box (SOLR and elasticsearch support this) or you can write your own finegrained schema file. This approach is my choice for huge liferay projects.

You can even distribute your shards over several machines. Elasticsearch does this ootb, SOLR has the so called SOLRCloud, that supports distribution.

Elasticsearch also allows you to define replicated shards and thus supports securing your applications search data a little better then SOLR does. Both search providers allow you to process JSON documents, SOLR also allows you to work with XML or CSV.

Elasticsearch is made for the cloud, and it supports big data integration with the "ELK stack" - Elasticsearch, Logstash, Kibana, as a Big Data analysis solution. Visit the following sites to learn:

Logstash: http://www.elasticsearch.com/products/logstash/
Kibana: http://www.elasticsearch.com/products/kibana/

While going through all the features that both search providers have, one could get the impression that there is no killer argument for one side of the "search battle". Both SOLR and elasticsearch can be used to perform the same things. While it is a very good idea from the liferay crew to integrate elasticsearch instead of a simple lucene index, there is no technological reason not to use SOLR. Elasticsearch seems to be a little easier to use out of the box and it is definetely a trending topic. Those might be two key points that lead to liferay´s decision to integrate it instead of SOLR.

So the bottom line is: Take the technology you prefer, there is no need to migrate to elasticsearch as long as you don´t need one of the central features they´re offering that SOLR doesn´t have. For all those of you who never thought about the search technology used by liferay under the hood: You will be able to distribute your indexes and have a much faster search then before.

Since elasticsearch is based on lucene it will be interesting to see how and if a migration will be possible.

Do you need expertise in SOLR, elasticsearch and / or liferay ? 
Just Contact me !

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