java.net.UnknownHostException while connectong to MySQL

Hello everybody, after using some other jabber server software, I really liked the idea of having a web interface for administering everything in a clean, easy way, which is exactly what your product seems to offer. The thing is, I haven’'t gotten to set it up correctly so far.

More specifically I’'m having problems connecting to a MySLQ database, everytime I try it keeps giving out the same error:

2005.07.27 13:28:59 [org.jivesoftware.database.ConnectionPool.(ConnectionPool.java:106)] Failed to create new connections on startup. Attempt 0 of 3

java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.UnknownHostException:

  • BEGIN NESTED EXCEPTION **

java.net.UnknownHostException

MESSAGE:

STACKTRACE:

java.net.UnknownHostException:

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.SocksSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at java.net.Socket.(ConnectionPool.java:83)

at org.jivesoftware.database.DefaultConnectionProvider.start(DefaultConnectionProv ider.java:83)

at org.jivesoftware.database.DbConnectionManager.setConnectionProvider(DbConnectio nManager.java:330)

at org.jivesoftware.messenger.admin.setup_002ddatasource_002dstandard_jsp._jspServ ice(setup_002ddatasource_002dstandard_jsp.java:269)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)

at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:822)

at org.jivesoftware.util.LocaleFilter.doFilter(LocaleFilter.java:43)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:813)

at org.jivesoftware.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingF ilter.java:41)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:813)

at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:78)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:813)

at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler. java:494)

at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:569)

at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)

at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.ja va:624)

at org.mortbay.http.HttpContext.handle(HttpContext.java:1434)

at org.mortbay.http.HttpServer.service(HttpServer.java:896)

at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)

at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)

at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)

at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)

at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:366)

at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

  • END NESTED EXCEPTION **

at com.mysql.jdbc.Connection.createNewIO(Connection.java:1851)

at com.mysql.jdbc.Connection.(ConnectionPool.java:83)

at org.jivesoftware.database.DefaultConnectionProvider.start(DefaultConnectionProv ider.java:83)

at org.jivesoftware.database.DbConnectionManager.setConnectionProvider(DbConnectio nManager.java:330)

at org.jivesoftware.messenger.admin.setup_002ddatasource_002dstandard_jsp._jspServ ice(setup_002ddatasource_002dstandard_jsp.java:269)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)

at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:822)

at org.jivesoftware.util.LocaleFilter.doFilter(LocaleFilter.java:43)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:813)

at org.jivesoftware.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingF ilter.java:41)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:813)

at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:78)

at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplica tionHandler.java:813)

at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler. java:494)

at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:569)

at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)

at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.ja va:624)

at org.mortbay.http.HttpContext.handle(HttpContext.java:1434)

at org.mortbay.http.HttpServer.service(HttpServer.java:896)

at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)

at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)

at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)

at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)

at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:366)

at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

It makes 3 tries and then dies giving an error on the database setup page. I’‘ve been looking all over the forums and on google to try to find an answer to this problem but I can’'t find a solution yet.

I’'ve tried replacing localhost with the machine hostname, ip and domain name and still keeps giving the same error (just changing with whatever I used to refer to the machine).

The MySQL database is up, the user is created and has permission for the database. I can connect to the database using the command line mysql tool, so I know it’'s not a problem with permissions or stuff like that.

I’'ve tried on 3 different machines (1 White Box Linux, 2 Fedora Core 2 boxes) and I get the same thing on each of them.

I’'ve used both betas and the stable rpms, and also I tried using the tarball and getting the JRE separately. All with the same result.

I’'ve also tried disabling all firewalls and anything that can be blocking connections without any luck

I would really appreciate it if someone could give me a hand with this problem, It’‘s honestly driving me insane since I can’‘t seem to find anyone on the forums or on the net that’‘s having this same problem and it’‘s very frustrating since I’'m practically all out on ideas on what to do next.

Thanks ahead for your help

Hi mmagallanes,

Wow, sounds like you’'ve tried just about everything. Which version of MySQL are you using? Have you tried downloading/using the url=http://dev.mysql.com/downloads/connector/j/3.1.htmllatest JDBC driver[/url] from MySQL?

Thanks,

Ryan

hey ryang

first of all thanks for answering so fast!

I’‘ve tried using versions 3.23.58, 4.1.10 and 4.1.12 and no, I haven’‘t tried using the latest driver but I’'m about to go try that and see if that fixes anything.

Thanks

Mario

Have you tried the loopback address – 127.0.0.1? UnknownHostException indicates that there is something very strange going on with the networking on your machine. You might try using the embedded database instead.

Regards,

Matt

Yeah, I was just going to say, if you’‘ve tried three different version of MySQL and none of them worked the driver isn’'t the likely problem (but still worth checking out).

Are you installing Messenger on the same machine as MySQL? If so, could you try installing it on another box for testng purposes?

Thanks,

Ryan

Well I tried the loopback address and I get the same thing, also like you said I tried installing the server and the database on different boxes and, surprise, I get the same thing.

I don’‘t know if I’‘m having “weird networking problems”, it’‘d be weird if I had since everything else that’‘s running on my servers is working fine, plus the 3 servers I’‘ve tried this on are all on totally diferent LAN’‘s, (one of them is even on a different city) so I don’‘t think there is some internal network problem, I mean I’‘m not closing the door on that possibility but it seems rather unlikely. Of course it also seems unlikely that I’‘d have the same problem over and over again on 3 different servers on 3 different network so right now I’'m totally puzzled about just what the devil is going on over here.

Oh yeah about the driver, I haven’‘t tried that yet, I guess that’‘s the next step from here cause I’‘m running out of options. I’'ll let you guys know how that works out.

Thanks for your help

Mario

Mario

Check your /etc/hosts file

The first line should be 127.0.0.1 localhost

with nothing else on that line. If you have multiple names on that line chances are your using a Redhat/Fedora flavour of Linux and this is a common problem.

The first line should only have the loopback and localhost.

move all others to the next line with IP.ADD.RESS hostname hostname.domain

Set that and try JM setup again.

Best of Luck

Peter

Hey pawad,

you know, after I read what you posted I really thought that could be it, so I went ahead and made the change (yes I am running fedora core) to the hosts file, but to add even more to my frustration it still gave me the same error, I tried both localhost and 127.0.0.1 on connection settings and both turned out the same.

I even rebooted the computer just in case and still nothing. I don’‘t know but this is turning out to be weirder than I thought, I’'d really like to set up the server but mysql connectivity is a must for me.

Thanks again for your help guys

Well then the next step is to fire up webmin or some GUI (I know its a bad word) and take a look at your table you added for Jive.

When I added my table I screwed up my permissions…

This is the fastest and easiest way to setup MySQL for Jive

mysqladmin -uroot -ppassword create jivemessenger

mysql -uroot -ppaswword

GRANT ALL PRIVILEGES ON jivemessenger.* TO ‘‘jive’’@’‘localhost’’ IDENTIFIED BY ‘‘some_pass’’;

flush privileges;

quit;

cat messenger_mysql.sql | mysql jivemessenger;

Then in JM admin make sure you put in localhost as the server and the user/pass that you specified above.

Everything should work from there.

If things dont work, double check to make sure that MySQL is setup with Network enabled. I’‘m not sure exactly where that is, but I’'ve seen a post in the past about securing MySQL but turning off network if its not being used.

Best of Luck

Peter

Hello there,

Well I’‘ve been really busy with some other stuff that came up so I hadn’‘t had the time to check this problem until just now, and so I tried the steps you posted about creating a database using the mysql admin program (I must admit, I’'ve always used webmin )

And what do you know, the problem is still there, the same unknown exception, and you know just now as I’‘m typing this I double checked the parameters I entered on the last attemp I made and I noticed I misspelled the database (jivemesengeer) and still, it didn’‘t complain about the database not existing or anything of the sort, just gave out the same unknown exception, so clearly it’'s dying in the attempt to connect to the database even before being able to check user permissions or existing databases, why is this is I guess the big question and the answer I got so far is I got no clue yet.

I don’‘t know how many levels of network awareness are there in the mysql setup, but usually the default installation on red hat derivate boxes seems to be network aware, as soon as the service is started it listens on port 3306, and I have succesfully connected from remote locations using CocoaMysql or Query Browser and stuff like that, so I don’‘t think that’'s where the problem is, again this is as far as I know so I could be wrong here.

I guess there’‘s nothing left but to try the driver thing, I’‘ve been postponing that since I have no idea how to go about and do it :stuck_out_tongue: and I wanted to avoid having to read even more documentation and just wanted to have the thing up and running, but wth, guess it’'s reading time.

I’'ll keep you guys posted, thanks again for your help

Regards

Mario

Have you tried SU-ing to your jivedb user and seeing if you can open MySQL and reading the jive database?

Peter

you might also try writing a basic jdbc java prog to do a basic query against the jm database using the same jvm/jars/etc that jm is using.

to eliminate any chance of property file conflict you could hard code all the parms.

-chip