aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First test attempt fails: log class '...Log4JLogger' cannot be found or is not useable. Why?
 
Similar Threads
problems in subpackage and imports
Strange error getting on the console
cannot deploy to jboss 5.0.1 server
JMSAppender and logging
How to import classes in a subpackage from another sub-package?