Setting up Liferay in JBoss 5.1
January 24th, 2010 by Bert WillemsTags:Hypersonic, Java, JBoss, Liferay
Welcome to the first article in a series of articles on Liferay. In this series I will show you various aspects of Liferay, Liferay installation, Liferay maintenance and Liferay development so lets get started. These articles assume that you have basic Java development skills.
In this post I will show you how to install Liferay 5.2.3, the latest communitie edition, on your local machine in the JBoss 5.1 application server, I assume you have a Windows machine. If you are running a different OS you can take the same steps but some paths will change depending on your OS. There are quite a few steps that need to be taken in order to set up Liferay, I will go through each and every step in detail.
Install the Java Development Kit 1.5
If you have installed the JDK already you can skip this section. In order to develop you need the Java SDK. The SDK contains things like the compiler and the base libraries. You can download the latest vesion from the Sun Java website. You need to download and install the JDK 5.0 Update 22 version. Once you have installed the SDK verify that the JAVA_HOME enviroment variable is set. Go to the enviroment variables settings of your computer and check if an entry JAVA_HOME exists in the system variables group, if not add it the value should point to the root directory of th SDK installation folder, for example: ‘C:\java\jdk1.5.0_21′. Next ensure that the PATH system variable includes the value ‘%JAVA_HOME%\bin’, if not add it. Save the settings if you made a modification.
You can verify if the SDK is installed and configured properly by executing the following command in a command window:
java -version
Is should print something like:
java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
Java is now properly installed.
Installing JBoss 5.1
Although Liferay can run in a host of application servers I chose the JBoss application server for these series. First step is to download JBoss application server 5.1GA from the JBoss website. Unzip the JBoss application server in a location of choice. I use ‘C:\java\jboss’, I call this path JBOSS_HOME directory. That is basically it.
You can start JBoss by double clicking on ‘%JBOSS_HOME%\bin\run.bat’. The JBoss console windows will popup and JBoss starts, it might take a few minutes before it is ready. When JBoss is completely started (look for this line [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)] Started in 1m:12s:239ms) go to http://localhost:8080/, you will see the default website here.
Shutdown the JBoss server by pressing CTRL+C in the JBoss console window.
Configuring the Java Authentication and Authorization Service
Open the file ‘%JBOSS_HOME%\server\default\conf\login-config.xml’ in a text editor of choice. Comment out the policy named other (defined in lines 110 and 129). After that it should look like this:
<!-- The default login configuration used by any security domain that
does not have a application-policy entry with a matching name
<application-policy name="other">-->
<!-- A simple server login module, which can be used when the number
of users is relatively small. It uses two properties files:
users.properties, which holds users (key) and their password (value).
roles.properties, which holds users (key) and a comma-separated list of
their roles (value).
The unauthenticatedIdentity property defines the name of the principal
that will be used when a null username and password are presented as is
the case for an unuathenticated web client or MDB. If you want to
allow such users to be authenticated add the property, e.g.,
unauthenticatedIdentity="nobody"
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required"/>
</authentication>
</application-policy>-->
This allows Liferay to add it’s own implementation.
Setting up a Datasource
In this post we will set up Liferay to work with Hypersonic, in a later post I will show you how to set up MySQL. Create a new file ‘%JBOSS_HOME%\server\default\deploy\liferay-ds.xml’ and set its content to:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/LiferayPool</jndi-name>
<connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url>
<driver-class>org.hsqldb.jdbcDriver</driver-class>
<user-name>sa</user-name>
<password></password>
<min-pool-size>0</min-pool-size>
</local-tx-datasource>
</datasources>
Setting up a Mailsource
I assume you have a mail server running on your local machine, if not configure the proper URLs forPOP and SMTP. Create a new file ‘%JBOSS_HOME%\server\default\deploy\mail-service.xml’ and set its content to:
<?xml version="1.0"?>
<server>
<mbean code="org.jboss.mail.MailService" name="jboss:service=MailSession">
<attribute name="JNDIName">mail/MailSession</attribute>
<attribute name="User">nobody</attribute>
<attribute name="Password">password</attribute>
<attribute name="Configuration">
<configuration>
<property name="mail.store.protocol" value="imap" />
<property name="mail.transport.protocol" value="smtp" />
<property name="mail.imap.host" value="localhost" />
<property name="mail.pop3.host" value="localhost" />
<property name="mail.smtp.host" value="localhost" />
</configuration>
</attribute>
</mbean>
</server>
Installing Liferay Dependencies
This is the last preperation before we can install Liferay. Liferay needs several dependencies in order to run correctly. You can download the dependencies from the Liferay website. Download them and unzip them in the ‘%JBOSS_HOME%\server\default\lib’.
Installing Liferay
Finally we can start installing Liferay. First delete all the files and folders of the JBoss root application, you can find them at ‘%JBOSS_HOME%\server\default\deploy\ROOT.war’. The directory must be left empty.
Download the Liferay portal WAR from the Liferay website. Unzip it in the ‘%JBOSS_HOME%\server\default\deploy\ROOT.war’ folder.
Delete jaxen.jar, jaxrpc.jar, stax.jar, xercesImpl.jar, xml-apis.jar from the ‘%JBOSS_HOME%\server\default\deploy\ROOT.war\WEB-INF\lib’ folder.
Create a new file ‘%JBOSS_HOME%\server\default\deploy\ROOT.war\WEB-INF\classes\portal-ext.properties’ and set its content to:
jdbc.default.jndi.name=jdbc/LiferayPool mail.session.jndi.name=mail/MailSession
That is it, fire up JBoss and Liferay will be installed. Once JBoss and Liferay are started(look for this line: [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)] Started in 2m:31s:673ms) go to http://localhost:8080/. You will see the Liferay portal now.
You can login using username ‘test@liferay.com’ and password ‘test’ (without the quotes ofcourse).
You have learned to setup Liferay with JBoss and Hypersonic. Take a moment to familiarize yourself with the Liferay portal: add some portlets, change layouts and themes. That is it for now! In the following posts I will show you how to change from Hypersonic to a different database engine and how to develop a Liferay portlet, layout and theme.
I hope you liked my article, if you have any question or feedback feel free to post a comment or contact me.
10 Replies to “Setting up Liferay in JBoss 5.1”
January 24th, 2010 at 20:59
[...] Liferay to use MySQL instead of Hypersonic. I assume you have followed all the steps in the previous post or that you are using a JNDI datasource. I also assume that you have installed MySQL on your system [...]
January 25th, 2010 at 16:11
This one seems to be odd: You’re downloading JDK 5.0 Update 22 (which has reached its EOL), pointing your path to update 21 and get a JDK 6 Update 17 when asking for its version
For us Liferay on JBoss has a very long startup time and a very high memory consumption in comparison to a tomcat liferay installation. Do you also see that? Are there any tricks regarding those issues?
January 25th, 2010 at 16:46
Hello Stefan,
You are right, the reason why it shows the wrong version number is that my machine runs several JDKs.
Tomcat is indeed light weight compared to JBoss, I am sure there are a lot of tweaks for JBoss, I am not an expert on JBoss though. When I find some performance tips I will share them here.
January 26th, 2010 at 12:46
[...] Dit blogartikel was vermeld op Twitter door bubbl, JohnnySoftware. JohnnySoftware heeft gezegd: RT @DZone "Setting up Liferay in JBoss 5.1" http://dzone.com/zpcC is a great article for Java programmers who simply want a portal now. [...]
March 4th, 2010 at 18:39
Hola,
estoy empezando a trabajar con liferay. Mi problema es que tengo un liferay con tomcat y en lugar de tomcat tengo que utilizar jboss.
Descargue de la pagina de liferay el liferay5.2.3 con el jboss 5.0, cogi el jboss y lo meti en la carpeta de mi liferay donde tenia el tomcat.En el jboss añadi el fichero portal-ext.properties.Arranque el jboss pero da error.
¿Alguien sabe lo que puede ser?.
Muchas gracias.
Un saludo.
Laura.
March 5th, 2010 at 08:48
Hello Laura,
My my spanish speaking colleague translated your question for me. If I understood well you copied the JBoss directory over the existing Tomcat directory.
Can you extract JBoss in a separate directory and run it? That might solve your problem.
Good luck!
Bert
April 17th, 2010 at 14:09
[...] a really simple JSR-168 portlet which can be deployed into Liferay. I assume you have read my previous articles and that you are using Liferay 5.2.3 on JBoss 5.1. I hope you like this post as much as [...]
May 25th, 2010 at 06:47
You didn’t mention the authentication. Do you recommend to to run everything in the “PortalRealm” of liferay or to use JAAS and run everything in a Jboss realm?
June 4th, 2010 at 05:41
Thanks for the instalation steps.
I have created a spring portlet could you please tell me how to deploy it.
Thanks in advance
June 11th, 2010 at 10:55
salam..
i wana connect my application deployed on liferay, with mysql..
plz help me…
i dont know how to do …
i don’t now if i have t use JNDI, if its that, plz tell me how