2

I'm trying to use h2 database on opensuse, but I can't make it work. I downloaded the platform independent package from the official web site, then tried several things to run it, without success :

  • Make the /h2/bin/h2.sh executable, then execute the console command ./h2.sh
  • Use the command java -jar h2*.jar
  • Use Play!Framework command h2-browser

All three return the same error :

org.h2.jdbc.JdbcSQLException: IO Exception: "java.net.UnknownHostException: linux-t89a.site: linux-t89a.site" [90028-170]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
        at org.h2.message.DbException.get(DbException.java:158)
        at org.h2.message.DbException.convert(DbException.java:273)
        at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:263)
        at org.h2.server.web.WebServer.updateURL(WebServer.java:325)
        at org.h2.server.web.WebServer.init(WebServer.java:315)
        at org.h2.tools.Server.<init>(Server.java:51)
        at org.h2.tools.Server.createWebServer(Server.java:412)
        at org.h2.tools.Console.runTool(Console.java:228)
        at org.h2.tools.Console.main(Console.java:100)
Caused by: java.net.UnknownHostException: linux-t89a.site: linux-t89a.site
        at java.net.InetAddress.getLocalHost(InetAddress.java:1454)
        at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:261)
        ... 6 more
Exception in thread "main" org.h2.message.DbException: IO Exception: "java.net.UnknownHostException: linux-t89a.site: linux-t89a.site" [90028-170]
        at org.h2.message.DbException.get(DbException.java:158)
        at org.h2.message.DbException.convert(DbException.java:273)
        at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:263)
        at org.h2.server.TcpServer.getURL(TcpServer.java:193)
        at org.h2.tools.Server.getStatus(Server.java:391)
        at org.h2.tools.Console.printProblem(Console.java:300)
        at org.h2.tools.Console.runTool(Console.java:270)
        at org.h2.tools.Console.main(Console.java:100)
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "java.net.UnknownHostException: linux-t89a.site: linux-t89a.site" [90028-170]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
        ... 8 more
Caused by: java.net.UnknownHostException: linux-t89a.site: linux-t89a.site
        at java.net.InetAddress.getLocalHost(InetAddress.java:1454)
        at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:261)
        ... 5 more

Here is my java -version :

java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (suse-3.37.1-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

My javac -version :

javac 1.7.0_21

Further info : I asked a friend to try to run it on UnbuntuX, with the java -jar h2*.jar procedure, and it worked (we have the same java version, linux distribution omitted). I asked another friend to try to run it on his computer with Opensuse, it didn't work, with the same error as mine.

Thanks

EDIT : As required, the content of the etc/hosts file :

#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#    
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1       localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts
Saffron
  • 682
  • 6
  • 14
  • The H2 server tries to connect to itself over TCP/IP, and it tries to use its own IP address for this. It uses normal Java API for this. It seems this doesn't always work if there is a problem with the network configuration. Could you post the contents of your `/etc/hosts` file as well please? – Thomas Mueller May 17 '13 at 14:06
  • 2
    Done, Maybe the error comes from the line 127.0.0.1 localhost Should I add ? 127.0.0.1 linux-t89a – Saffron May 17 '13 at 14:22
  • According to the answer in the linked question (see below): yes. I wonder if I should change H2 so that it doesn't use InetAddress.getLocalHost(), or works around this problem in some way. – Thomas Mueller May 17 '13 at 20:13
  • Still getting the problem in Opensuse 13.1. @Saffron 's comment fixes it. Check name after unknownHostException In my case Add 127.0.0.1 dhcppc4 – Rich Oliver Mar 16 '14 at 02:39

2 Answers2

4

I think the problem is that the method InetAddress.getLocalHost() does not work in your environment for some reason. The H2 database uses this method.

This problem and a possible answer is described in the question InetAddress.getLocalHost() throws UnknownHostException

Community
  • 1
  • 1
Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
  • 1
    Thanks a lot! Managed to make it work thanks to you. For anyone who's looking for a solution, you can actually change the /etc/hosts file, by adding a line with your IP adress and the name of the host in your unknown host exception. exemple : "127.0.0.1 arandomname" – Saffron May 21 '13 at 07:13
0

I am encountering this issue as well, and my situation works like this:

  1. Connect machine to VPN. This process assigns a unique hostname to my machine. This hostname changes every time I connect to the VPN.
  2. Close down the connection to VPN.
  3. Start up H2 in tcp mode.

This situation might be alleviated by instead calling InetAddress.getByName("127.0.0.1"). I reviewed the JDK source for this method and it appears that because the address is an IP address it skips the DNS lookup / loopbackAddress code flow.