jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlo Paglia (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JCR-3464) Clustering Jackrabbit with Liferay 5.2.3 over IBM DB2
Date Tue, 27 Nov 2012 13:43:57 GMT
Carlo Paglia created JCR-3464:
---------------------------------

             Summary: Clustering Jackrabbit with Liferay 5.2.3 over IBM DB2
                 Key: JCR-3464
                 URL: https://issues.apache.org/jira/browse/JCR-3464
             Project: Jackrabbit Content Repository
          Issue Type: Bug
          Components: jackrabbit-core, sql
    Affects Versions: 1.5.3
         Environment: Liferay 5.2.3 on JBoss 5.1.2 GA over IBM DB2
            Reporter: Carlo Paglia


Hi guys, i just want to share with you solutions to some bugs that occour in jackrabbit cluster
configuration on IBM DB2.
Two kind of problems occour:

DatabaseJournal.java in /org/apache/jackrabbit/core/journal/ can't create J_C_ tables due
to missing db2.ddl file in that package.
Here is the sql script that you have to put in it:

CREATE TABLE ${schemaObjectPrefix}JOURNAL (REVISION_ID BIGINT NOT NULL, JOURNAL_ID VARCHAR(255),
PRODUCER_ID VARCHAR(255), REVISION_DATA BLOB )
CREATE UNIQUE INDEX ${schemaObjectPrefix}JOURNAL_IDX ON ${schemaObjectPrefix}JOURNAL (REVISION_ID)

CREATE TABLE ${schemaObjectPrefix}GLOBAL_REVISION (REVISION_ID BIGINT NOT NULL)
CREATE UNIQUE INDEX ${schemaObjectPrefix}GLOBAL_REVISION_IDX ON ${schemaObjectPrefix}GLOBAL_REVISION
(REVISION_ID)

CREATE TABLE ${schemaObjectPrefix}LOCAL_REVISIONS ( JOURNAL_ID varchar(255), REVISION_ID BIGINT
NOT NULL)

# Inserting the one and only revision counter record now helps avoiding race conditions
INSERT INTO ${schemaObjectPrefix}GLOBAL_REVISION VALUES(0)


Classes located in /org/apache/jackrabbit/core/ cannot acquire connections from datasource,
due to a bug in ConnectionFactory.java in package /org/apache/jackrabbit/core/persistence/bundle/util/;
below is reported the fixed source code: 

package org.apache.jackrabbit.core.persistence.bundle.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class ConnectionFactory
{
public static Connection getConnection(String driver, String url, String user, String password)
throws RepositoryException, SQLException
{
if ((driver != null) && (driver.length() > 0)) {
try {
Class d = Class.forName(driver);
if (Context.class.isAssignableFrom(d))
{
Context context = (Context)d.newInstance();
DataSource ds = (DataSource)context.lookup(url);
//Here is the bug: the original version doesn't check the empty string
//case in user and password properties.
if ((user == null || user.equals("")) && (password == null || password.equals("")))
{
return ds.getConnection();
}
return ds.getConnection(user, password);
}

try
{
d.newInstance();
}
catch (Throwable e)
{
}
}
catch (ClassNotFoundException e) {
throw new RepositoryException("Could not load class " + driver, e);
} catch (InstantiationException e) {
throw new RepositoryException("Could not instantiate context " + driver, e);
} catch (IllegalAccessException e) {
throw new RepositoryException("Could not instantiate context " + driver, e);
} catch (NamingException e) {
throw new RepositoryException("Naming exception using " + driver + " url: " + url, e);
}
}
return DriverManager.getConnection(url, user, password);
}
}

Hope it helps!!! Enjoy!
Carlo

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message