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

   http://java.sun.com/javase/downloads/index.jsp
   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)

   http://ant.apache.org/bindownload.cgi
   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

   http://www.mysql.org/downloads/mysql/5.0.html
   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

   http://www.mysql.org/downloads/gui-tools/5.0.html
   
   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 MySQL.org 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 liferay-portal-sql-4.2.2.zip 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

   http://sourceforge.net/project/downloading.php?groupname=jboss&filename=jems-installer-1.2.0.GA.jar
   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)

   http://sourceforge.net/project/showfiles.php?group_id=49260
   

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"

      <init-param>
         <param-name>input</param-name>
         <param-value>4096</param-value>
      </init-param>
      <init-param>
         <param-name>output</param-name>
         <param-value>4096</param-value>
      </init-param>

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="*"/>
      

19)Download liferay-portal-dependencies-4.2.2.zip

   http://sourceforge.net/project/showfiles.php?group_id=49260
   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

   http://www.mysql.org/downloads/connector/j/5.0.html      
   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

<datasources>

   <local-tx-datasource>
      <jndi-name>jdbc/LiferayPool</jndi-name>
      <connection-url>jdbc:mysql://localhost/liferay?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>liferay</user-name>
      <password>liferay</password>
      <min-pool-size>0</min-pool-size>
   </local-tx-datasource>

</datasources>

   
   

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 portal.properties in Archive [LIFERAY]/WEB-INF/web.xml

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

28)Modify portal.properties 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
   shutdown.programmatically.exit=false
   
   // 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
   #auto.deploy.dest.dir=../webapps
   auto.deploy.dest.dir=../server/default/deploy
   auto.deploy.unpack.war=false
   
   // little performance tuning
   javascript.fast.load=true
   // set the omniadmin to your domain and give him an initial Passwort and Name
   omniadmin.users=[DOMAIN].1
   default.admin.password=[INIT-PASSWORD]
   default.admin.email.address.prefix=admin
   default.admin.first.name=Admin
   default.admin.last.name=Admin
   // Change paths where liferay stores it's data in filesystem
   // You can you relative paths based to [JBOSS_HOME]/bin
   auto.deploy.deploy.dir=../../liferay/deploy
   lucene.dir=../../liferay/lucene/
   jcr.jackrabbit.repository.root=../../liferay/jackrabbit
   dl.root.dir=../../liferay/documentlibrary/root/
   dl.version.root.dir=../../liferay/documentlibrary/vroot/
   

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
16228 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments