jQuery in Action, 2nd edition*
The moose likes Testing and the fly likes First test attempt fails: log class '...Log4JLogger' cannot be found or is not useable. Why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Testing
Bookmark "First test attempt fails: log class Watch "First test attempt fails: log class New topic
Author

First test attempt fails: log class '...Log4JLogger' cannot be found or is not useable. Why?

Edward Winchester
Ranch Hand

Joined: Sep 16, 2009
Posts: 65
Hello,

I'm using Netbeans 6.7.1 to develop my app. I've just written a DAO to store a file in a database and want to test it using JUnit 4.5. When I run the test I am getting an error: smallFile caused an ERROR (User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.)

Here's my unit test code:



The FileStoreDAOImpl uses commons-logging which is pointed at Log4J. Here's a snippet of class FileStoreDAOImpl:



I have verified that commons-logging is available on my classpath. I even replaced the code in test "smallFile" with some code to print out a classpath and can see the commons-logging.jar there.

Can someone help me get past this problem please?

Thanks,

Ed
Edward Winchester
Ranch Hand

Joined: Sep 16, 2009
Posts: 65
I got it to work but it doesn't make sense to me why it works.

In the Project Properties, under Libraries category and the Compile Tests tab, I had Log4j.1.2.15 library specified. (The library references log4j-1.2.15.jar).
To make it work I also added the jar explicitly. Perhaps this is a Netbeans 6.7.1 bug?

Anyway, I think I can carry on for now but I would like to understand exactly what's going on as it make me feel a bit uncomfortable.

Ed
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Log4J also needs to be on your classpath; I doubt it's a bug. It's more likely that the test execution classpath wasn't what you thought it was.
 
GeeCON Prague 2014
 
subject: First test attempt fails: log class '...Log4JLogger' cannot be found or is not useable. Why?