I'm having some real trouble getting ha-jdbc running since jboss 4.2.2
Whatever I try it can never find my config file.
I keep getting this error:
java.sql.SQLException: Failed to locate database cluster configuration file: ha-jdbc-cluster1.xml
This file exists: /opt/jboss/server/default/deploy/ha-jdbc-cluster1.xml
This is a snippet from my jboss datasource file:
<no-tx-datasource>
<jndi-name>cluster</jndi-name>
<connection-url>jdbc:ha-jdbc:cluster1</connection-url>
<driver-class>net.sf.hajdbc.sql.Driver</driver-class>
<!-- the minimum size of the connection pool -->
<min-pool-size>2</min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>40</max-pool-size>
Without a config property defined, HA-JDBC is trying to locate the file ha-jdbc-{0}.xml in the classpath, where {0} matches the cluster id specified in the jdbc url, jdbc:ha-jdbc:{0}.
To force HA-JDBC to look in a specific location, you should instead use something like this:
Thanks for that, it got me a little further on now.
I'm getting some incompatible version for jibx now.
Have you seen this before?
org.jibx.runtime.JiBXException: Incompatible binding version for class net.sf.hajdbc.sql.DriverDatabaseCluste
r, recompile binding with current JiBX distribution
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I downgraded jibx to 1.1.6a and that solved the incompatible binding problem, now it is finding the ha-jdbc-cluster1.xml file but I'm getting a weird problem with the configuration file.
I get this error:
org.jibx.runtime.JiBXException: Expected "cluster" end tag, found "datasource" start tag (line 3, col 3)
I don't understand why it expects to close the cluster tag before the datasource tag
The relevant section of my jboss datasource
<no-tx-datasource>
<jndi-name>cluster</jndi-name>
<connection-url>jdbc:ha-jdbc:cluster1</connection-url>
<driver-class>net.sf.hajdbc.sql.Driver</driver-class>
<!-- the minimum size of the connection pool -->
<min-pool-size>2</min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>40</max-pool-size>
But now I have a different error, it seems to have problem writing the state. Apparently "indent-number" is not supported?
17:18:57,918 INFO [AbstractDatabaseCluster] Initializing HA-JDBC 2.0.15 from file:/opt/jboss/server/default/deploy/ha-jdbc-cluster1.xml
17:18:58,035 ERROR [STDERR] 26/04/2009 17:18:58 java.util.prefs.FileSystemPreferences$7 run
WARNING: Prefs file removed in background /home/jpearson/.java/.userPrefs/net/sf/hajdbc/local/prefs.xml
17:18:58,035 INFO [LocalStateManager] No initial cluster state found.
17:18:58,500 ERROR [AbstractDatabaseCluster] Failed to start database cluster cluster1.
java.lang.RuntimeException: Failed to store state of database cluster cluster1.
....
Caused by: java.util.prefs.BackingStoreException: java.lang.IllegalArgumentException: Not supported: indent-number
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh I see. Do you know if it's possible to disable the preferences and just keep all the settings in memory? We don't need any of the synchronisation features so we're happy if the preferences are reset every time jboss is restarted.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm having some real trouble getting ha-jdbc running since jboss 4.2.2
Whatever I try it can never find my config file.
I keep getting this error:
java.sql.SQLException: Failed to locate database cluster configuration file: ha-jdbc-cluster1.xml
This file exists: /opt/jboss/server/default/deploy/ha-jdbc-cluster1.xml
This is a snippet from my jboss datasource file:
<no-tx-datasource>
<jndi-name>cluster</jndi-name>
<connection-url>jdbc:ha-jdbc:cluster1</connection-url>
<driver-class>net.sf.hajdbc.sql.Driver</driver-class>
<!-- the minimum size of the connection pool -->
<min-pool-size>2</min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>40</max-pool-size>
</no-tx-datasource>
What am I doing wrong??
I appears that you are expecting the contents of <config>...</config> to be read as the configuration file location. When accessed via a JDBC url, only the <connection-property/> elements are passed through to Driver.connect(String, Properties). Details here:
http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/Connectors_on_JBoss-Configuring_JDBC_DataSources.html
Without a config property defined, HA-JDBC is trying to locate the file ha-jdbc-{0}.xml in the classpath, where {0} matches the cluster id specified in the jdbc url, jdbc:ha-jdbc:{0}.
To force HA-JDBC to look in a specific location, you should instead use something like this:
<no-tx-datasource>
<jndi-name>cluster</jndi-name>
<connection-url>jdbc:ha-jdbc:cluster1</connection-url>
<driver-class>net.sf.hajdbc.sql.Driver</driver-class>
<connection-property name="config">file:///opt/jboss/server/default/deploy/ha-jdbc-cluster1.xml</connection-property>
...
</no-tx-datasource>
Thanks for that, it got me a little further on now.
I'm getting some incompatible version for jibx now.
Have you seen this before?
org.jibx.runtime.JiBXException: Incompatible binding version for class net.sf.hajdbc.sql.DriverDatabaseCluste
r, recompile binding with current JiBX distribution
I downgraded jibx to 1.1.6a and that solved the incompatible binding problem, now it is finding the ha-jdbc-cluster1.xml file but I'm getting a weird problem with the configuration file.
I get this error:
org.jibx.runtime.JiBXException: Expected "cluster" end tag, found "datasource" start tag (line 3, col 3)
This is my ha-jdbc-cluster1.xml file.
<ha-jdbc>
<cluster balancer="round-robin" dialect="PostgreSQL" default-sync="net.sf.hajdbc.sync.PassiveSynchronizationStrategy" transaction-mode="serial" meta-data-cache="lazy">
<datasource id="database1">
<name>java:database1</name>
</datasource>
<datasource id="database2">
<name>java:database2</name>
</datasource>
</cluster>
</ha-jdbc>
I don't understand why it expects to close the cluster tag before the datasource tag
The relevant section of my jboss datasource
<no-tx-datasource>
<jndi-name>cluster</jndi-name>
<connection-url>jdbc:ha-jdbc:cluster1</connection-url>
<driver-class>net.sf.hajdbc.sql.Driver</driver-class>
<!-- the minimum size of the connection pool -->
<min-pool-size>2</min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>40</max-pool-size>
</no-tx-datasource>
Ok I changed my ha-jdbc-cluster1.xml file to have the databases inline for the meantime to make the errors go away. It is now like so:
<ha-jdbc>
<sync id="passive" class="net.sf.hajdbc.sync.PassiveSynchronizationStrategy">
</sync>
<cluster balancer="round-robin" dialect="PostgreSQL" default-sync="passive" transaction-mode="serial" meta-data-cache="lazy">
<database id="database1">
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://127.0.0.1:5432/database</url>
<user>user</user>
<password>passwd</password>
</database>
<database id="database2">
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://127.0.0.1:5466/database</url>
<user>user</user>
<password>passwd</password>
</database>
</cluster>
</ha-jdbc>
But now I have a different error, it seems to have problem writing the state. Apparently "indent-number" is not supported?
17:18:57,918 INFO [AbstractDatabaseCluster] Initializing HA-JDBC 2.0.15 from file:/opt/jboss/server/default/deploy/ha-jdbc-cluster1.xml
17:18:58,035 ERROR [STDERR] 26/04/2009 17:18:58 java.util.prefs.FileSystemPreferences$7 run
WARNING: Prefs file removed in background /home/jpearson/.java/.userPrefs/net/sf/hajdbc/local/prefs.xml
17:18:58,035 INFO [LocalStateManager] No initial cluster state found.
17:18:58,500 ERROR [AbstractDatabaseCluster] Failed to start database cluster cluster1.
java.lang.RuntimeException: Failed to store state of database cluster cluster1.
....
Caused by: java.util.prefs.BackingStoreException: java.lang.IllegalArgumentException: Not supported: indent-number
"Caused by: java.util.prefs.BackingStoreException: java.lang.IllegalArgumentException: Not supported: indent-number "
It is a well known bug of older version of Java http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519088.
Upgrade your JRE/JDk.
Cheers
Oh I see. Do you know if it's possible to disable the preferences and just keep all the settings in memory? We don't need any of the synchronisation features so we're happy if the preferences are reset every time jboss is restarted.