Archive for November, 2010

Grails ConnectionPool error with MySQL on FreeBSD

When trying to get Grails to work on one of my machines I kept getting the following error when I tried to deploy the production WAR file.

nested exception is org.springframework.jdbc.support.MetaDataAccessException:
 Error while extracting DatabaseMetaData;
 nested exception is org.apache.commons.dbcp.SQLNestedException:
   Cannot create PoolableConnectionFactory (Access denied for user 'test_user'@'127.0.0.1' (using password: YES))

This had me really confused because I had changed nothing except where the database was.  In the dev and testing environment I’m using a remote database while in production environment the database is on the same machine as the code.  I took the same WAR file and moved it over to a Linux machine and everything seems to work with no problems there.  This got me even more confused.

After staring at the error for a little while I narrowed the problem down to how I was setting up the user’s permissions in MySQL.  They way I created the user’s permissions on all machines was this:

GRANT ALL PRIVILEGES ON appdb.* to 'appuser'@'localhost' IDENTIFIED BY 'super-secret-pass' ;

Turns out MySQL on FreeBSD really doesn’t like this when you have the DB setup in Grails as “localhost”. For some reason I still don’t quite understand it uses the IP and not the DNS alias when authenticating. I can see how this might be faster. No need to do name resolution, but still, just makes thing harder.

The fix was to just create the user with the host set to 127.0.0.1.

GRANT ALL PRIVILEGES ON appdb.* to 'appuser'@'127.0.0.1' IDENTIFIED BY 'super-secret-pass' ;

Adding mod_proxy to Apache 2.2 in FreeBSD

I was trying to install mod_proxy in my Apache install and got into some problems.  When trying to use the ports system to recompile Apache with mod_proxy I kept getting the following error.

make reinstall
===>  Installing for apache-2.2.14_5
===>   apache-2.2.14_5 depends on file: /usr/local/bin/perl5.8.9 - found
===>   apache-2.2.14_5 depends on shared library: expat.6 - found
===>   apache-2.2.14_5 depends on shared library: pcre.0 - found
===>   apache-2.2.14_5 depends on shared library: iconv.3 - found
===>   Generating temporary packing list
===>  Checking if www/apache22 already installed
===>   apache-2.2.14_5 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of www/apache22
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop in /usr/ports/www/apache22.
*** Error code 1

Stop in /usr/ports/www/apache22.
*** Error code 1

Stop in /usr/ports/www/apache22.

Read some articles here and here where the solution was to deinstall and then reinstall.  Hell no!  My configuration is just how I want it and I’m not going to change everything because the ports systems is very badly broken!

The problem doesn’t seem to happen on compilation but when ports is trying to modify the current install.  So the next thing I did was look around in what did get compiled and try to find the modules I wanted.

$ pwd
/usr/ports/www/apache22
$ find . -type f -name '*proxy*.so'
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_connect.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_http.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_ajp.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_balancer.so

There they are and they look good.  So the next thing I did was to copy those over to my current apache install:

$ cp `find . -type f -name '*proxy*.so'` /usr/local/libexec/apache22/

Add the correct module loading bits:

# grep proxy /usr/local/etc/apache22/httpd.conf
LoadModule proxy_module libexec/apache22/mod_proxy.so
LoadModule proxy_http_module libexec/apache22/mod_proxy_http.so
LoadModule proxy_balancer_module libexec/apache22/mod_proxy_balancer.so

And when I restarted apache everything was working just fine. Woo-hoo!

Return top