Mavericks, MacPorts, PostgreSQL 9, Tomcat 6 and PostgreSQL Studio

Now that Amazon Web Services is supporting PostgreSQL I figured it’s about time I got around to getting it setup locally.

First step was to install PostgreSQL via MacPorts:

# install and select
sudo port install postgresql93-server
sudo port select –set postgresql postgresql93
# load at startup
sudo port load postgresql93-server
# create the default database
sudo mkdir -p /opt/local/var/db/postgresql93/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
# create a new user (or you can simply use the default user postgres which does not require a password)
createuser –superuser your_username -U postgres -P
# create a new database
createdb database_name

view raw
postgresql.sh
hosted with ❤ by GitHub

You should now be able to connect to your database using pgAdmin or a similar tool. If you’re having trouble, a quick reboot of your machine should get it working (assuming you set PostgreSQL to load at startup).

I also wanted to try out PostgresSQL Studio which requires Tomcat so that got installed next:

# install
sudo port install tomcat6
# add -Djava.awt.headless=true to /opt/local/share/java/tomcat6/bin/tomcatctl (line 65)
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true"
# without this you’ll get this error in /opt/local/share/java/tomcat6/logs/catalina.err:
# 2013-11-16 23:39:17.389 jsvc[1698:203] Apple AWT Java VM was loaded on first thread — can't start AWT.
# Nov 16, 2013 11:39:17 PM org.apache.catalina.startup.Bootstrap initClassLoaders
# SEVERE: Class loader creation threw exception
# java.lang.InternalError: Can't start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application's Info.plist or on the command line
# load at startup
sudo port load tomcat6

view raw
tomcat.sh
hosted with ❤ by GitHub

Installing Tomcat led to a momentary headache as it would not start, throwing the following error – Apple AWT Java VM was loaded on first thread — can’t start AWT. All of the OS X / MacPorts / Tomcat instructions on Google were pretty out of date so it took a bit of digging to figure out what was going on. Luckily the fix was rather simple – just edit tomcatctl with the change shown in the Gist above.

The final step was to download PostgreSQL Studio, unzip the file and drop pgstudio.war into /opt/local/share/java/tomcat6/webapps/.

After a few moments Tomcat will autodeploy the war and you’ll be able to browse the application at http://localhost:8080/pgstudio/.

2 thoughts on “Mavericks, MacPorts, PostgreSQL 9, Tomcat 6 and PostgreSQL Studio”

  1. Thanks for putting this together. I had some problems with bash_profile and had to delete it to allow port to work but other than that all went well. Great to see something like PostgreSQL Studio too.

Leave a Reply to David Brimley Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s