Maven sucks?

Kent Spillner certainly seems to think so. I disagree with the conclusion, but I find myself agreeing with a lot of the points he makes. It’s true that maven builds aren’t always consistent across different platforms or even maven versions. It’s also true that your pom.xml file can grow rather large and complicated if you want to get maven to do interesting things. And it’s definitely very true that maven dependency management can be hair-pullingly-complicated and is essentially broken. Sure.

But saying that writing your own build manager is better? Advocating ant and rake? Seriously? Maven does a lot more than just build your project. It does reporting, site generation, eclipse project generation and pretty much anything else you can think of. The convenience of the thing is worth a lot. It’s definitely worth having to struggle with the POM every once in a while. And to be honest, the POM syntax isn’t much more horrible than ant’s or rake’s.

As for platform/version inconsistencies: if you can’t force the people on your team to use the same software, then your problems probably run a lot deeper than just build management. Software has bugs, this includes maven as well. If you’ve hit a particular bug that causes your build to go kaboom, then fixing it sounds like the way to go.

If you have the time to write a build manager for every project you work on, be my guest. I for one don’t, and maven has actually served me pretty well so far.

Howto: PostgreSQL data source in JDeveloper/OC4J

Today I had to create a postgres connection pool in JDeveloper’s embedded oc4j container. JDeveloper being the horrible piece of software that it is, and its documentation being rather lacking, this took a lot longer than it should have. The pretty GUI wizards aren’t able to pull it off either — these measly conjurers really aren’t worthy of the name.

The biggest hurdly was postgres’ connection pool not being happy with just a jdbc URL. Instead it expects a hostname, port number and database name. These things are all in the jdbc url, but never mind, that would’ve been too simple. After reading through the XSD for data-sources.xml, I realised that there’s an option to provide custom properties to the factory. Quite simple really. A connection pool definition looks something like this:

<connection-pool name="myPool" disable-server-connection-pooling="false">
	<connection-factory
		factory-class="org.postgresql.jdbc3.Jdbc3PoolingDataSource"
		user="postgres" password="1234"
		url="jdbc:postgresql://localhost:5432/db">
		<property name="serverName" value="localhost" />
		<property name="portNumber" value="5432" />
		<property name="databaseName" value="db" />
	</connection-factory>
</connection-pool>
<managed-data-source name="dataSource" jndi-name="jdbc/postgresDS" connection-pool-name="myPool" />

Once this is done, all that’s left to do is place the postgres driver JAR in the j2ee/home/applib folder in your JDeveloper folder. If you don’t place it there, you’ll get very nice class not found errors.

That’s it. Not very hard at all!