Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I missed a payment for my server and hey suspended my account for a day or so. When they brought the server back up all my data was in tact but for some reason Tomcat can't make a JDBC connection to my MySql server. They both run on the same machine and hence I have a bind address of 127.0.0.1.

It's strange because I have reset the machine of my own accord before without issue but clearly something has been reset in the downtime.

I followed this guide (Just the bits which don't concern S3, I am not on Amazon infrastructure) originally and everything worked as expected.

I'm very new to being a SysAdmin and I'm not sure what to try, how would you go about diagnosing this issue? The stack trace I get is as follows;

INFO: Deploying web application archive myapp-1.1.war
2010-05-26 22:07:22,221 [main] ERROR context.ContextLoader  - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:129)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:714)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:404)
        at org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext.refresh(GrailsWebApplicationContext.java:153)

...

I get this error for a number of 'beans'.

If I type mysql at my command prompt then I can easily login with the same credentials as my grails app which uses GORM and Hibernate to persist objects to the DB.

I might not have given enough info to start with but I'm really interested to learn and will certainly provide it if asked, I just really don't know where to start on this one.

UPDATE: I can connect to mysql by running the binary at the command line. I also ran mysql over tcp and couldn't connect, does this spread any light on the issue?

root@88:~# mysql -u grails --protocol=tcp -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (110)

I have bind-address as 127.0.0.1 as previously discussed so maybe it's not a surprise this doesn't work. Is there anything I need to check in my hosts file?

Thanks,

Gav

share|improve this question
1  
It turned out my lo interface was down. ifconfig lo up fixed it. –  gav Jun 4 '10 at 8:57
add comment

2 Answers

up vote 0 down vote accepted

The main difference between using the mysql command-line utility and using the MySQL JDBC driver is that the mysql command will use a Unix socket file by default (e.g. /tmp/mysql.sock), whereas the JDBC driver always uses TCP/IP.

Try forcing the mysql command to use TCP/IP as well, by passing the --protocol=tcp option, and see what happens. This might give you a more illuminating error message (or, if it succeeds, that will tell us something too).

share|improve this answer
    
root@88:~# mysql -u grails --protocol=tcp -p Enter password: ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (110) –  gav May 27 '10 at 8:23
    
Hi Matt, thanks for getting back to me, it seems I can't connect over TCP! Has this narrowed the issue to my.cnf? Or maybe I had to specify a port with the command? See the update in the original question. Thanks. –  gav May 27 '10 at 8:28
add comment

First things first, make sure the MySQL server is up and running:

sudo /etc/init.d/mysqld status

If it is not, start it:

sudo /etc/init.d/mysqld start
share|improve this answer
    
It's started and running, I can log in using mysql on the command line and all my data and tables are still in tact. –  gav May 27 '10 at 16:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.