Reputation: 707
I am trying to create an automated integration test against a running local JBoss 5.1 instance where I need to make assertions against the database. The appserver is configured with a HSQL datasource in server mode in order to be accessible through TCP.
These are the relevant (I think) parts of the configuration:
<connection-url>jdbc:hsqldb:hsql://${jboss.bind.address}:1701</connection-url>
<driver-class>org.hsqldb.jdbcDriver</driver-class>
<user-name>sa</user-name>
<password></password>
<mbean code="org.jboss.jdbc.HypersonicDatabase"
name="jboss:service=Hypersonic">
<attribute name="Port">1701</attribute>
<attribute name="BindAddress">${jboss.bind.address}</attribute>
<attribute name="Silent">true</attribute>
<attribute name="Database">default</attribute>
<attribute name="Trace">false</attribute>
<attribute name="No_system_exit">true</attribute>
</mbean>
It works in that the deployed application runs fine and I am also able to connect to the database using external tools such as "hsqldbclient" and the Eclipse "Data Source Explorer".
The problem is that when I try to get a connection from my test case the connection is closed immediately and I get a "Broken Pipe" error.
This is how I try to get a connection:
DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:1701", "sa", "");
This is the error I get on the client side:
Caused by: org.hsqldb.HsqlException: connection exception: connection failure: java.net.SocketException: Broken pipe
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ClientConnection.execute(Unknown Source)
at org.hsqldb.ClientConnection.<init>(Unknown Source)
And this is the error I get on the server side:
09:46:04,132 ERROR [STDERR] Exception in thread "HSQLDB Connection @fa3b82"
09:46:04,133 ERROR [STDERR] java.lang.NullPointerException
09:46:04,133 ERROR [STDERR] at org.hsqldb.ServerConnection.close(Unknown Source)
09:46:04,133 ERROR [STDERR] at org.hsqldb.ServerConnection.run(Unknown Source)
09:46:04,133 ERROR [STDERR] at java.lang.Thread.run(Thread.java:662)
I am at a loss in trying to interpret what is happening. It looks like the connection is being made and then immediately closed by the server but the connection is then null which causes a nullpointer to be thrown. Note that this is all on the same machine and I am able to connect using other tools but with the same connection URL as described above.
If anyone has any ideas of what to try I would be very grateful.
Upvotes: 2
Views: 3610
Reputation: 24372
I have not tried this but if your connection is made in the app server, you may be able to connect directly to the database with :
DriverManager.getConnection("jdbc:hsqldb:file:default", "sa", "");
You may need to use the full path to the default database.
The NPE is probably a bug in the version of HSQLDB used. Try replacing the hsqldb.jar with a later one, for example HSQLDB 1.8.1.3.
Upvotes: 3
Reputation: 707
I found the problem after looking into what versions of HSQLDB were used (the answer from fredt gave me the idea).
For some reason the client was using HSQLDDB 2.0 but JBoss 5.1 comes with 1.8. I changed the client to also use 1.8 and the problem went away. Quite simple really but I was stuck for nearly a day with this.
Upvotes: 3