I have 2 different application which individually have ha-jdbc configuration and setup packaged in different applications under the same tomcat. When the server is started, first application initializes the ha-jdbc connections correctly but the second one throws the following exceptions:
ERROR o.h.util.JDBCExceptionReporter - Unable to open a test connection to the given database. JDBC url = jdbc:ha-jdbc:re, username = postgres. Terminating connection pool. Original Exception:
java.lang.ClassCastException: net.sf.hajdbc.balancer.LoadBalancer cannot be cast to net.sf.hajdbc.Balancer
at $Proxy56.getBalancer(Unknown Source)
at net.sf.hajdbc.sql.AbstractRootInvocationHandler.<init>(AbstractRootInvocationHandler.java:44)
at net.sf.hajdbc.sql.DriverInvocationHandler.<init>(DriverInvocationHandler.java:38)
at net.sf.hajdbc.sql.Driver.connect(Driver.java:86)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
......
Is there is limitation that one server can have only one ha-jdbc running ?
Anonymous
Do these HA-JDBC configurations refer to the same logical set of databases? Assuming yes, you'll need to move the HA-JDBC configuration to the server level (i.e. move the ha-jdbc jars from your jar into CATALINA_HOME/lib and the config from context.xml to server.xml). The problem is, the first application creates the necessary objects using the application's classloader, but then registers its mbeans with the platform mbean server. When the second application attempts to access the cluster, it reads the registered mbean, but cannot load its classes, since it was created with an inaccessible classloader.
I've already fixed this issue in HA-JDBC master.