Menu

getting started with Liferay 6.1/Tomcat 7/HAJDBC

Help
2013-08-14
2013-08-14
  • Cory Sawyer

    Cory Sawyer - 2013-08-14

    Hello, I need a little help getting started. I'm trying to use HA-JDBC to allow a liferay instance to be ha behind a load balancer.

    I can get it to work using the raw postgres driver, but when I move to use the ha-jdbc driver, I'm seeing some connection errors: "java.sql.SQLException: No active databases in cluster net.sf.hajdbc.sql.DatabaseClusterImpl@27865448"

    using liferay 6.1.1
    tomcat 7.0.37
    .../lib/ext/postgresql-9.1-901.jdbc4.jar
    .../lib/ext/ha-jdbc-2.1.0-beta-4.jar

    portal-ext.properties (works with org.postgresql.Driver)

    jdbc.default.driverClassName=net.sf.hajdbc.sql.Driver
    jdbc.default.url=jdbc:ha-jdbc:cluster1
    #jdbc.default.driverClassName=org.postgresql.Driver
    #jdbc.default.url=jdbc:postgresql://localhost:5432/lportal
    jdbc.default.username=asmadmin
    jdbc.default.password=adminasm
    

    WEB-INF/classes/ha-jdbc-cluster1.xml

    <ha-jdbc xmlns="urn:ha-jdbc:cluster:2.1">
       <sync id="passive"/>
       <state id="simple"/>
       <cluster default-sync="passive"
                balancer="simple"
                dialect="postgresql"
                meta-data-cache="none"
                transaction-mode="parallel">
          <database id="database1" weight="1" location="jdbc:postgresql://localhost:5432/lportal">
             <user>asmadmin</user>
             <password>adminasm</password>
          </database>
          <database id="database2" weight="0" location="jdbc:postgresql://localhost:5433/lportal">
             <user>asmadmin</user>
             <password>adminasm</password>
          </database>
       </cluster>
    </ha-jdbc>
    

    Stack Trace:

    WARN  08-14-13 14:20:44:044 com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#9 com.mchange.v2.resourcepool.BasicResourcePool com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@3cb5b49 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (3). Last acquisition attempt exception: 
    java.sql.SQLException: No active databases in cluster net.sf.hajdbc.sql.DatabaseClusterImpl@27865448
        at net.sf.hajdbc.sql.SQLExceptionFactory.createException(SQLExceptionFactory.java:51)
        at net.sf.hajdbc.sql.SQLExceptionFactory.createException(SQLExceptionFactory.java:35)
        at net.sf.hajdbc.invocation.InvokeOnOneInvocationStrategy.invoke(InvokeOnOneInvocationStrategy.java:73)
        at net.sf.hajdbc.invocation.InvocationStrategies.invoke(InvocationStrategies.java:35)
        at net.sf.hajdbc.sql.AbstractInvocationHandler.invokeOnProxy(AbstractInvocationHandler.java:95)
        at net.sf.hajdbc.sql.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:85)
        at net.sf.hajdbc.sql.ChildInvocationHandler.invoke(ChildInvocationHandler.java:44)
        at $Proxy31.getTransactionIsolation(Unknown Source)
        at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:107)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:198)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:148)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
        at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
    

    any help or hints would be appreciated.

    Thanks so much!

     
  • Paul Ferraro

    Paul Ferraro - 2013-08-14

    The actual connection errors should be visible in your log as DEBUG messages. I'll fix this so that the initial connection errors are logged using a higher priority.
    For now, try lowering your log threshold to see the actual connection error.

     
  • Cory Sawyer

    Cory Sawyer - 2013-08-14

    This DEBUG statement is quite telling:
    DEBUG 08-14-13 16:55:47:047 main net.sf.hajdbc.sql.DatabaseClusterImpl Method org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented. org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented.
    at org.postgresql.Driver.notImplemented(Driver.java:753)
    at org.postgresql.jdbc4.AbstractJdbc4Connection.isValid(AbstractJdbc4Connection.java:109)
    at org.postgresql.jdbc4.Jdbc4Connection.isValid(Jdbc4Connection.java:21)
    at net.sf.hajdbc.dialect.StandardDialect.isValid(StandardDialect.java:1004)
    at net.sf.hajdbc.sql.DatabaseClusterImpl.isAlive(DatabaseClusterImpl.java:837)
    at net.sf.hajdbc.sql.DatabaseClusterImpl.start(DatabaseClusterImpl.java:708)
    at net.sf.hajdbc.util.concurrent.LifecycleRegistry.get(LifecycleRegistry.java:76)
    at net.sf.hajdbc.util.concurrent.LifecycleRegistry.get(LifecycleRegistry.java:1)
    at net.sf.hajdbc.sql.Driver.connect(Driver.java:139)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:221)
    at net.sf.hajdbc.CLSTest.main(CLSTest.java:43)

    Any known workaround? This is the latest pg driver that I could find (9.1.901.jdbc4)
    thanks
    -c

     
  • Cory Sawyer

    Cory Sawyer - 2013-08-14

    updating the driver did indeed help.

    thanks for your help and update!

     

Log in to post a comment.