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)
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)
WEB-INF/classes/ha-jdbc-cluster1.xml
Stack Trace:
any help or hints would be appreciated.
Thanks so much!
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.
FYI: https://github.com/ha-jdbc/ha-jdbc/commit/2af3d18c00c713a8bdb72432dd7da0159d4b3fac
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
The latest PostgreSQL driver version is 9.1-903:
http://jdbc.postgresql.org/download/postgresql-9.1-903.jdbc4.jar
Looking at the source, Connection.isValid(...) is indeed implemented in this version.
Ultimately, the validation of a connection is handled by the Dialect (see https://github.com/ha-jdbc/ha-jdbc/blob/master/src/main/java/net/sf/hajdbc/dialect/Dialect.java#L258). So, if the PostgreSQL implementation (i.e. https://github.com/ha-jdbc/ha-jdbc/blob/master/src/main/java/net/sf/hajdbc/dialect/postgresql/PostgreSQLDialect.java) is not to your liking, you can always override it.
updating the driver did indeed help.
thanks for your help and update!