
Setup Liferay using MySQL under JBOSS
in any of the supported application servers (including JBoss) using any of the supported databases (including MySQL)
check the Documentation Center.
I don't know whether someone has the same problem, but if so, here are the steps I had to make to get Liferay on JBOSS working with MySQL:
Requirements:
I assume you have a working MySQL installation with the proper scripts run to create your Liferay database with name "lportal" and you set up a
database named jboss and created the necesarry tables init. I also assume that the user root has the following password: password.
Known issues:
There is some problem with log4j versions used in JBOSS and Liferay I didn't manage to get rid of this error yet. The error states: Could not instantiate appender named "FILE".
1. I downloaded the original JBOSS bundle from here
Downloaded file: liferay-portal-jboss-tomcat-4.2-5.2.3.zip
I extracted it into the location where I wanted to install Liferay let's call this directory to {JBOSS_HOME}!
The extracted directory sturcure is:
{JBOSS_HOME}
|
|-data
|-deploy
|-jboss-tomcat-4.2.3
|-license
|-readme.html
2. In liferay-ds.xml located in {JBOSS_HOME}/jboss-tomcat-4.2.3/server/default/deploy/liferay-ds.xml I defined the datasource for the MySQL server:
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/LiferayPool</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding= UTF-8&useFastDateParsing=false</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>password</password>
<min-pool-size>5</min-pool-size>
</local-tx-datasource>
</datasources>
3. Delete the file hsqldb-ds.xml from {JBOSS_HOME}/jboss-tomcat-4.2.3/server/default/deploy/
4. Create the file myqldb-ds.xml in {JBOSS_HOME}/jboss-tomcat-4.2.3/server/default/deploy/ with the following content:
<datasources>
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/jboss?useUnicode=true&characterEncoding=UTF-8 &useFastDateParsing=false</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>password</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter </exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor. MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
5. Delete the file hsql-jdbc2-service.xml from {JBOSS_HOME}/jboss-tomcat-4.2.3/server/default/deploy/jms/
6. Create the file mysql-jdbc2-service.xml in {JBOSS_HOME}/jboss-tomcat-4.2.3/server/default/deploy/jms/ with the following content:
<!-- $Id: mysql-jdbc2-service.xml 39343 2005-12-29 16:32:35Z ltexier $ -->
<server>
<!-- ==================================================================== -->
<!-- Persistence and caching using MySQL -->
<!-- IMPORTANT: Remove hsqldb-jdbc2-service.xml -->
<!-- -->
<!-- ==================================================================== -->
<!--
| The destination manager is the core service within JBossMQ
-->
<mbean code="org.jboss.mq.server.jmx.DestinationManager" name="jboss.mq:service=DestinationManager">
<depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache</depends>
<depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager</depends>
<depends optional-attribute-name="StateManager">jboss.mq:service=StateManager</depends>
</mbean>
<!--
| The MessageCache decides where to put JBossMQ message that
| are sitting around waiting to be consumed by a client.
|
| The memory marks are in Megabytes. Once the JVM memory usage hits
| the high memory mark, the old messages in the cache will start getting
| stored in the DataDirectory. As memory usage gets closer to the
| Max memory mark, the amount of message kept in the memory cache aproaches 0.
-->
<mbean code="org.jboss.mq.server.MessageCache"
name="jboss.mq:service=MessageCache">
<attribute name="HighMemoryMark">50</attribute>
<attribute name="MaxMemoryMark">60</attribute>
<attribute name="CacheStore">jboss.mq:service=PersistenceManager</attribute>
</mbean>
<!-- The PersistenceManager is used to store messages to disk. -->
<!--
| The jdbc2 PersistenceManager is the new improved JDBC implementation.
| This implementation allows you to control how messages are stored in
| the database.
|
| This jdbc2 PM configuration has was supplied by Stephane Nicoll in the forums as an example for MySQL
-->
<mbean code="org.jboss.mq.pm.jdbc2.PersistenceManager"
name="jboss.mq:service=PersistenceManager">
<depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name= DefaultDS</depends>
<attribute name="SqlProperties">
BLOB_TYPE=BYTES_BLOB
INSERT_TX = INSERT INTO JMS_TRANSACTIONS (TXID) values(?)
INSERT_MESSAGE = INSERT INTO JMS_MESSAGES (MESSAGEID, DESTINATION, MESSAGEBLOB, TXID, TXOP) VALUES(?,?,?,?,?)
SELECT_ALL_UNCOMMITED_TXS = SELECT TXID FROM JMS_TRANSACTIONS
SELECT_MAX_TX = SELECT MAX(TXID) FROM JMS_MESSAGES
DELETE_ALL_TX = DELETE FROM JMS_TRANSACTIONS
SELECT_MESSAGES_IN_DEST = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE DESTINATION=?
SELECT_MESSAGE_KEYS_IN_DEST = SELECT MESSAGEID FROM JMS_MESSAGES WHERE DESTINATION=?
SELECT_MESSAGE = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=? MARK_MESSAGE =
UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE MESSAGEID=? AND DESTINATION=?
UPDATE_MESSAGE = UPDATE JMS_MESSAGES SET MESSAGEBLOB=? WHERE MESSAGEID=? AND DESTINATION=?
UPDATE_MARKED_MESSAGES = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE TXOP=?
UPDATE_MARKED_MESSAGES_WITH_TX = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE TXOP=? AND TXID=?
DELETE_MARKED_MESSAGES_WITH_TX = DELETE JMS_MESSAGES FROM JMS_MESSAGES, JMS_TRANSACTIONS WHERE JMS_MESSAGES.TXID = JMS_TRANSACTIONS.TXID AND JMS_MESSAGES.TXOP=?
DELETE_TX = DELETE FROM JMS_TRANSACTIONS WHERE TXID = ?
DELETE_MARKED_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXID=? AND TXOP=?
DELETE_TEMPORARY_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXOP='T'
DELETE_MESSAGE = DELETE FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
CREATE_MESSAGE_TABLE = CREATE TABLE JMS_MESSAGES (MESSAGEID INTEGER NOT NULL, DESTINATION VARCHAR(150) NOT NULL, TXID INTEGER, TXOP CHAR(1), MESSAGEBLOB LONGBLOB, PRIMARY KEY (MESSAGEID, DESTINATION))
CREATE_IDX_MESSAGE_TXOP_TXID = CREATE INDEX JMS_MESSAGES_TXOP_TXID ON JMS_MESSAGES (TXOP, TXID)
CREATE_IDX_MESSAGE_DESTINATION = CREATE INDEX JMS_MESSAGES_DESTINATION ON JMS_MESSAGES (DESTINATION)
CREATE_TX_TABLE = CREATE TABLE JMS_TRANSACTIONS ( TXID INTEGER, PRIMARY KEY (TXID) )
CREATE_TABLES_ON_STARTUP = TRUE
</attribute>
<!-- Uncomment to override the transaction timeout for recovery per queue/subscription, in seconds -->
<!--attribute name="RecoveryTimeout">0</attribute-->
<!-- The number of blobs to load at once during message recovery -->
<attribute name="RecoverMessagesChunk">1</attribute>
</mbean>
</server>
7. Setup portal-ext.properties in {JBOSS_HOME}\jboss-tomcat-4.2.3\server\default\deploy\ROOT.war\classes to use MySQL datasource:
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=password
jdbc.default.jndi.name=jdbc/LiferayPool
If you have some question or suggestion, correction, please don't hesitate to tell me! I hope it helps a bit.