Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Maven 2 hates Commons Logging

It's true that most people hate commons-logging, but Maven 2 hates it even more. There are many open source projects that use this library, so you're likely to depend on it when you never intended to. Of course, this is Maven 2's transitive dependencies fault - but currently there's no option to turn transitivity off. I tried changing to SLF4J, but that causes some Maven plugins to fail.

Since the Maven team refuses to fix this (even though it's an *obvious* exception to their rule about not changing anything), I've fixed it myself. The AppFuse repo has a fixed version of commons-logging's pom.xml. To get the fixed version of commons-logging, delete it from your local repo, then add AppFuse's repository to your pom.xml:

    <repositories>
        <repository>
            <id>appfuse</id>
            <url>http://static.appfuse.org/repository</url>
        </repository>
    </repositories>

Since the burden of this issue clearly rests upon the shoulders of the commons-logging developers - can we please get a new release with a fixed pom? Pretty please?

Update: I tried to get slf4j to work again today. While I succeeded, I found a critical bug. The bug is that log messages don't print out the method name, just debug(), info() or whatever from your classes. It's possible to fix this by using slf4j instead of clogging. However, that won't help you get method names printed when cranking up the logging for 3rd party libraries like Spring and Hibernate. Since this won't be fixed, it seems better to stick with commons-logging. I doubt I'd have any luck getting all the libraries that AppFuse uses to move away from commons-logging.

Posted in Java at Feb 04 2007, 10:43:15 PM MST 11 Comments
Comments:

I've also had a lot of problems with commons logging for this exact same reason however a couple of days ago I found out about the ability to exclude dependencies from another project's import. This is the POM import I've used for commons logging &

<dependency>
	<groupId>commons-logging</groupId>
	<artifactId>commons-logging</artifactId>
	<version>1.1</version>
	<scope>compile</scope>
	<exclusions>
		<exclusion>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
		</exclusion>
		<exclusion>
			<groupId>logkit</groupId>
			<artifactId>logkit</artifactId>
		</exclusion>
		<exclusion>
			<groupId>avalon-framework</groupId>
			<artifactId>avalon-framework</artifactId>
		</exclusion>
		<exclusion>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
		</exclusion>
	</exclusions>
</dependency>
Using this does not prevent you from re-importing a dependency but it does mean that you can get rid of any problems that might arise.

Posted by Andy Yates on February 05, 2007 at 09:49 AM MST #

Of course, another option is to explicitly exclude commons-logging, and add dependency for jcl104-over-slf4j, which is basically a slf4j who implements commons-logging interface. You can read more about it at http://www.slf4j.org/manual.html#gradual

Posted by David Rabinowitz on February 05, 2007 at 06:55 PM MST #

David - I tried that. The hibernate3-maven-plugin barfs with a NoClassDefFoundError. I sent e-mails (this morning) to both the slf4j and mojo mailing lists to try to find a resolution.

Posted by Matt Raible on February 05, 2007 at 07:05 PM MST #

After exchanging emails with Matt, it looks like he did not include any binding as a dependency. Matt thought that since slf4j-simple was declared in the pom file of jcl-over-slf4j as a dependency, it would be included by transitivity. However, the slf4j-simple dependency is marked with the provided scope, so that it is *not* included transitivitely.

Posted by Ceki Gulcu on February 05, 2007 at 07:36 PM MST #

They just need to cut a new release, i don't know why they wait so long, i imagine not enought users have bothered them.

And adding your own modified commons-logging to your repo is really a bad idea.
- if i already have it cached (most likely) i won't get it from your repo
- if i get it from you other projects may not work


So the easiest solution would be to create org.appfuse.thirparty commons-logging pom (type pom) that depends on commons-logging 1.1 with all the exclusions, and make appfuse use that one until 1.1.1 is released

Posted by Carlos Sanchez on February 06, 2007 at 11:20 PM MST #

I myself had the issue that commons-logging was importing servlet-api in my ear thus effectively making my webapp not work. I think it's a crime not to fix this and add servlet-api as provided, as it makes webapps fail TODAY instead of other apps that might fail but probably no-one will notice. Why in the hell's name would anyone want to import servlet-api into a project is beyond me. Just go with the flow Sanchez and correct this blatant mistake!

Posted by Srgjan Srepfler on February 09, 2007 at 08:49 PM MST #

The SLF4J bug mentioned by Matt has been fixed in SLF4J version 1.3.

Posted by Ceki Gulcu on February 22, 2007 at 01:41 PM MST #

Thanks for posting this info Matt, I was quite puzzled and you and the posters were really helpful :)

Posted by Fabricio on May 11, 2007 at 05:28 PM MDT #

Matt, The Commons Logging team is preparing the 1.1.1 release. As far as I can tell, the bug will be fixed in Commons Logging 1.1.1: https://issues.apache.org/jira/browse/LOGGING-113

Posted by Commons Logging user on July 31, 2007 at 04:20 AM MDT #

Commons Logging 1.1.1 does indeed fix the problem. Thanks for the pointer.

Posted by Jason Harrop on April 02, 2008 at 06:34 AM MDT #

<p>[Trackback] I just ran into some trouble using maven and some logging-APIs. </p> <p> First I had an issue with Maven2, Log4J and JMX dependencies. Here is a very good hint: <a href="http://onemanwenttomow.wordpress.com/2007/12/31/maven2-log4j-and-jmx-dependencies/">http://onemanwenttomow.wordpress.com/2007/12/31/maven2-log4j-and-jmx-dependencies</a></p> <p> After that...</p>

Posted by Olis Thoughts About Programming on December 22, 2008 at 12:26 PM MST #

Post a Comment:
  • HTML Syntax: Allowed