Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Prem Kashyap
Connecting to MySQL DB using JNDI lookup
December 14, 2009 4:42 AM
Answer

Prem Kashyap

Rank: New Member

Posts: 2

Join Date: December 14, 2009

Recent Posts

Hi,

Liferay Portal Standard Edition 5.2.3
MySQL 5.0.45- Community Edition

Steps to configure Liferay with MySQL DB (InnodDB Engine) using JNDI lookup.

Tasks 1 - ROOT Webapp

Unzip portal-impl.jar which is inside the folder LIFERAY_HOME/webapps/ROOT/WEB-INF/lib
Search for file portal.properties and extract it to the folder - LIFERAY_HOME/webapps/ROOT/WEB-INF/classes
Rename the extracted file to portal-ext.properties
Comment out the following lines in the file -
# include-and-override=portal-ext.properties
#include-and-override=${liferay.home}/portal-ext.properties
I am not sure if commenting the above lines is needed. But i did commented it.

Search for jdbc.default.jndi.name=jdbc/LiferayPool in the file.
Uncomment the above line in the file. So now you will be using JNDI lookup for the database.

Open the file ROOT.xml inside the folder LIFERAY_HOME/conf/Catalina/localhost
Copy the following line -
<ResourceLink global="jdbc/LiferayPool" name="jdbc/LiferayPool" type="javax.sql.DataSource"/>

Tasks 2 - wol-portlet

Go to folder LIFERAY_HOME/webapps/wol-portlet/WEB-INF/classes/META-INF
Open the file - ext-spring.xml
Comment out the following lines -
<!-- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/jdbc.properties</value>
</property>
<property name="placeholderPrefix" value="${jdbc." />
</bean> -->
<!-- <bean id="jiraDataSourceTarget" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.jira.driverClassName}" />
<property name="url" value="${jdbc.jira.url}" />
<property name="username" value="${jdbc.jira.username}" />
<property name="password" value="${jdbc.jira.password}" />
</bean> -->

Uncomment the following line -

<bean id="jiraDataSourceTarget" class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName">
<value>jdbc/JIRAPool</value>
</property>
</bean>

Not sure if the below 2 steps is needed. But there is no harm in doing it.

Go to folder LIFERAY_HOME/webapps/wol-portlet/META-INF
Open the file - context.xml
Add the following line -
<ResourceLink global="jdbc/JIRAPool" name="jdbc/JIRAPool" type="javax.sql.DataSource"/>

Copy the context.xml to folder LIFERAY_HOME/conf/Catalina/localhost
Rename it as wol-portlet.xml

Tasks 3 - Creating Database and users

Create the following database and users as follows -

Start MySQL
Run the following scripts from MySQL Prompt -

create database lportal character set utf8;
grant usage on lportal.* to luser@localhost identified by 'lpass';
grant all privileges on lportal.* to luser@localhost;

grant usage on lportal.* to 'luser'@'%' identified by 'lpass';
grant all privileges on lportal.* to 'luser'@'%';


Now you have database created. lportal for ROOT as well as for jira

Tasks 4 -

Creating Resource in server.xml
Open the server.xml file under LIFERAY_HOME/conf
Add the following resource under <GlobalNamingResources>
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" maxActive="50" maxIdle="10" maxWait="10000"
removeAbandoned="true" removeAbandonedTimeout="240" validationQuery="SELECT 1" name="jdbc/LiferayPool" password="lpass" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/lportal" username="luser" />

<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" maxActive="50" maxIdle="10" maxWait="10000"
removeAbandoned="true" removeAbandonedTimeout="240" validationQuery="SELECT 1" name="jdbc/JIRAPool" password="lpass" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/lportal" username="luser" />

Assumption - the mysql jdbc jar is in ext/lib folder.

Now you are good to start the server and your Liferay with MySQL should be working well and fine.

All the Best

Prem Kashyap
Lisa Simpson
RE: Connecting to MySQL DB using JNDI lookup
February 5, 2010 9:59 AM
Answer

Lisa Simpson

Rank: Liferay Legend

Posts: 2034

Join Date: March 5, 2009

Recent Posts

Things like this should be added to the WIKI