I’ve had a few people contact me in the last two weeks about problems starting up their JBoss-ColdFusion installation because of errors with Apache Commons Logging. This, unfortunately, is a common problem and it’s not an easy 1-2-3 fix. The problem arises when a third-party library or application is loaded that uses a newer version of commons logging than ColdFusion does.

In Java application servers, there’s an order in which applications are deployed. In JBoss, the default is alphabetical order inside the server directory. Let’s assume you have an app called BaseballStats stored in baseball.war. Then another application, such as the JMX Console that comes with JBoss, is in jmx-console.war.

The baseball.war application is deployed first with the commons-logging.jar file in ColdFusion’s classpath (WEB-INF\cfusion\lib) which is version 1.0.2, I believe. Then the jmx-console application tries to deploy and it needs version 1.0.7 located in jboss\server\default\deploy\lib.

This type of situation leads to CLASSPATH exceptions such as –

  • org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException
  • You have more than one version of ‘org.apache.commons.logging.Log’ visible

What you need to do in situations like this is ensure that ColdFusion loads the latest version of the Apache Commons Logging library available to it before it attemtps to load the one with which it shipped. You designate this in your web.xml file. Search for the text cf.class.path in this file and ensure that the location of the latest Commons Logging library is the first entry in the classpath.

For example, if you need to use the one shipped with your version of JBoss, an sample entry would look like this. I added the path to the JBoss lib directory before the references to the ColdFusion lib directory. This ensures that it will look at JBoss first to find a library before it looks in its own collection.

<-- Comma-delimited list of classpath locations relative to app root  -->
<context-param id="macromedia_context_88">
	<param-name>cf.class.path</param-name>
	<param-value>
		../../lib,
		./WEB-INF/cfusion/lib/updates,
		./WEB-INF/cfusion/lib,
		./WEB-INF/cfusion/gateway/lib.,
		./WEB-INF/cfform/jars
	</param-value>
</context-param>