Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why

Liferay with EJB3 and JBoss,

This article constains the all steps to setup Liferay as a WAR in JBoss with EJB3 on a windows machine. Some steps may differ for Linux bases systems. MySQL is used in this article for database layer.

Warning #

1. Please do not start JBoss until your proceed all steps.

2. Please don't use an editor which has problems with file encoding. We had some strange errors when we used for example wordpad or notepad (windows) to modify some jboss xml files.

Instructions #

1) Download and Install Java 6 SDK
   Add [JAVA_HOME] to Environment Variable JAVA_HOME
   Add [JAVA_HOME]/bin to Environment Variable PATH

2) Donwload Apache Ant 1.7.0 and install (uncompress)
   Add [ANT_HOME]/bin to Environment Variable PATH
   Test installation with "ant" from bash/shell. It should tell you
   that it can not find a build.xml.   

3) Download and Install MySQL 5
   Add [MYSQL_HOME]/bin to Environment Variable PATH (automatically by setup)
   Configuration: Developer Machine, Transactional Database Only, Strict Mode, UTF-8 Encoding
   If an erroroccured while the setup tries to apply configuration wait a while and press
   retry. Sometimes the service is not finished up with starting.
   Your should adapt settings for your productive systems.

4) Download and Install MySQL GUI-Tools 5
   Start MySQL Administrator GUI Tool and set Default Storage Engine to InnoDB (if not made during MySQL-Setup)
   (Startvariables -> Default Storage)
   We use InnoDB, because it supports foreign key constraints. LEP can be also installed with an MyISAM Database/Tables.
   WARNING: Be sure InnoDB is installed/supported, otherwise mysql will not
   restart next time. XAMPP for example uses a mysql bundle, where InnoDB is
   not available. It is recommended to install a MySQL-Server version downloaded
   from directly 

5) Start MySQL Console

   Create User "jboss" with password "jboss" and full access to database "jboss"
   Create User "liferay" with password "liferay" and full access to database "liferay"
   Create User "[YOUR-BUSINESSLOGIC-DB]" with password "[YOUR-BUSINESSLOGIC-DB]" and full access to database "[YOUR-BUSINESSLOGIC-DB]"
   For productive use you should make users bound to localhost or change passwords!

6) Download and uncompress create-minimal/create-minimal-mysql.sql

   Replace first Lines with "USE LIFERAY;", Start MySQL Console and import this sql-file via "source c:/.../create-minimal-mysql.sql;"
   This initialized LEP Tables with the minimal content to run.

7) Download JEMS-Installer 1.2.0
   Install with Profile "ejb3" and Select "Advanced" Mode
   Configure Database, Select MySQL Database, Username: jboss, Password: jboss, jdbc:mysql://localhost:3306/jboss
   We use MySQL as database layer for JBoss because for default JBoss uses Hypersonic with less performance
   JMX Security: admin-username: root, admin-password: [ROOT-PASSWORD]

8) Download liferay-portal-4.2.2.war and uncompress it to [JBOSS_HOME]/server/default/deploy (Foldername liferay-portal-4.2.2.war)

9) Delete in [LIFERAY]/META-INF/MANIFEST.MF the ClassPath Entry

   You have to do this, because JBoss will otherwise look for all these jars and will not find them and will answer it with a large exception

10)Modify [LIFERAY]/WEB-INF/jboss-web.xml and add "<context-root>/</context-root>" after "<security-domain>java:/jaas/PortalRealm</security-domain>"


11)Delete [JBOSS_HOME]/server/default/deploy/jbossweb-tomcat55.sar/ROOT.war

12)Modify [JBOSS_HOME]/server/default/deploy/jbossweb-tomcat55.sar/META-INF/jboss-service.xml

   and set Attribute Java2ClassLoadingCompliance (Line 51) and UseJBossWebLoader (Line 58) to "true"
   This is for JBoss/Tomcat Classloading behaviour and the only (as i know) way to make external portlets run fine.

13)Modify [JBOSS_HOME]/server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml

   Uncomment Line 225-228, so Java5 (Enums, Generics, "foreach", ...) can be used in JSP files

14)Add in [JBOSS_HOME]/server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml Servlet "default"


15)Create Directory [JBOSS_HOME]/server/default/lib/liferay

16)Rename [JBOSS_HOME]/server/default/conf/log4j.xml to jboss-log4j.xml

17)Modify [JBOSS_HOME]/server/default/conf/jboss-service.xml and replace

   line 107 with <attribute name="ConfigurationURL">resource:jboss-log4j.xml</attribute>

18)Modify [JBOSS_HOME]/server/default/conf/jboss-service.xml and add

   <classpath codebase="${jboss.server.lib.url:lib}/liferay" archives="*"/> after
   <classpath codebase="${jboss.server.lib.url:lib}" archives="*"/>

   Extract 3 jars to [JBOSS_HOME]/server/default/lib/liferay

20)Download Connector/J 5.0.5 and copy it to [JBOSS_HOME]/server/default/lib/liferay      
   Sometimes v5.0.5 makes problems. If this occur take v5.0.3 which works fine for a long time for us. 

21)Create liferay-ds.xml DataSource Definition in [JBOSS_HOME]/server/default/deploy





22)Modify [JBOSS_HOME]/server/default/mail-service.xml and enter you mailserver properties (host, login, password, protocol)

   The default LEP Tutorial for setting up LEP in JBoss says to change service and JNDI name like below:

<server> <mbean code="org.jboss.mail.MailService" name="jboss:service=MailSession"> <attribute name="JNDIName">mail/MailSession</attribute> ... </server>


23)Modify [JBOSS_HOME]/server/default/deploy/jbossjca-service.xml

   and set Line 63 to <attribute name="Debug">false</attribute>

24)Modify [JBOSS_HOME]/server/default/conf/jboss-log4j.xml

   Add <priority value="INFO"/> after "<root>" (Line 262)
   There exists some bugs in JSF/Spring which log recurive in debug-mode (not sure about this is actual)

25)Modify [JBOSS_HOME]/server/default/conf/login-config.xml and

   comment out full application-policy "other"

26)Modify [JBOSS_HOME]/server/default/deploy/jms/jbossmq-destinations-service.xml

   and comment out all between <server> and </server>

27)Modify in Archive [LIFERAY]/WEB-INF/web.xml

   Change company_id value to your [DOMAIN] (Line 6)

28)Modify in Archive [LIFERAY]/WEB-INF/lib/portal-ejb.jar

   (if your Compress-Tool does not support Archive rewrite you have to uncompress and compress again later)
   // This destroys Threads "manually" and is a hack for Tomat
   // JBos throws a lot of exception setting/leaving it to true
   // Change the deploy directory to jboss directory
   // Don't unpack deployed wars, otherwise you can get problems with
   // undeploying, because file locks on jars in /WEB-INF/lib of your deployed war
   // little performance tuning
   // set the omniadmin to your domain and give him an initial Passwort and Name
   // Change paths where liferay stores it's data in filesystem
   // You can you relative paths based to [JBOSS_HOME]/bin

29)Modify [JBOSS_HOME]/bin/run.bat and set -Xms512m -Xmx1024m (Line 81)

   This will increase memory of VM for JBoss
   To debug remotely for example with MyEclipse you can enable Remote debuggin with uncommenting (not for productive use)
   and set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS% (Line 87)
   For Linux/Mac Environment make changes in [JBOSS_HOME]/bin/run.conf
   JAVA_OPTS="-Xms512m -Xmx1024m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000" (Line 43)
   JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" (Line 47)

30)Modify [JBOSS_HOME]/bin/shutdown.bat

   Append somwhere after Line 27 
   set ARGS=%ARGS% -S --user=[ROOTLOGIN] --password=[ROOTPASSWORD]
   So you can shutdown JBoss with shutdown.bat

31)Start JBoss ([JBOSS_HOME]/bin/run.bat). Server should be up in less than 30 second with this settings :)

   Login on http://localhost:8080 with login "admin@[DOMAIN]" and password "[INIT-PASSWORD]"

32)Change the Admin Passwort to [ADMINPASSWORD]

Enterprise Beans (Session, Entity) 3 #

We deploy Entity Beans in a PAR archive and the Session Beans/Message Beans/Jboss Services in JAR archive inside of an EAR archive.

You can now use your businesslogic in your portlet.

0 Attachments
Average (0 Votes)
The average rating is 0.0 stars out of 5.