Saturday, November 14, 2009

Reinstalling PostgreSQL - deleting the "postgres" service account

I was playing around with PostgreSQL 8.4 for my personal project. After my initial installation, I uninstalled it and tried to reinstall it. During the installation, I was prompted to enter the password for the "postgres" service account, which I don't remember. To continue with the installation, I needed to enter the following command and create a new password

net user /delete postgres

Friday, November 6, 2009

Removing external Javascript from Spring 3 documentation with jEdit

The Spring 3 reference in HTML format loads Javascript files from external sites. It's a bit annoying to wait for the loading of the scripts, particularly when I need to navigate between the pages frequently.

I used jEdit to search for the following regular expressions in the HTML files and replace them with a space
(?s)Begin Google Analytics code.*End Google Analytics code

(?s)Begin LoopFuse code.*End LoopFuse code

Thursday, November 5, 2009

Problems creating a JDBC resource with Glassfish 3 and PostgreSQL 8.4 drivers

What I initially thought was a straight-forward task turns out to be more complex than I imagined. After dumping the jars for PostgreSQL 8.4 driver (postgresql-8.3-701.jdbc3.jar
, postgresql-8.4-701.jdbc4.jar) into <GLASSFISH>/domains/domain1/lib/databases, I started the GF 3 server and tried to create a connection pool. I tried to create a javax.sql.ConnectionPoolDataSource resource using org.postgresql.ds.PGConnectionPoolDataSource. However I kept getting this error:
Can't find ConfigModel.Property for attr -isolation-level-guaranteed on interface com.sun.enterprise.config.serverbeans.JdbcConnectionPool

I get this error even when I do not specifiy "guranteed" for the isolation level.

Googling around,  I finally found someone with a similar problem. Seems that there is a bug in some of the earlier builds, so I downloaded the latest build (build 70)and reinstalled GF3.

All's well? Not quite. When I tried to start the server, I get some problem with using port 7676 for the default JMS host. I dont think I've gotten this error before in the older builds. Well, I did change the http-listener-2 port in domain1's domain.xml, not sure if I introduced some typo error there, so I ran
asadamin verify-domain-xml

and checked that the domain.xml is ok. The error is something along the line of
java.net.SocketException: Address family not supported by protocol family: bind

It turns out that for some reason the new GF3 build has problem using Vista's default hosts file (at C:\Windows\System32\drivers\etc).

To get it to work, change
::1 localhost

to
127.0.0.1 localhost
#::1 localhost

Restart the server again.

Now proceed to create the connection pool. However, according to the PostgreSQL driver download website,
It comes in two flavors, JDBC3 and JDBC4. If you are using the 1.6 JVM, then you should use the JDBC4 version.

.....

JDK 1.6 - JDBC4. Support for JDBC4 methods is limited. The driver builds, but the majority of new methods are stubbed out.

So, you'll need to specify an additional property JDBC30DataSource and set it to true when configuring the connection pool. That should be about it, now you can get some real work done.