When running a PowerMock Test Log4j gives me the following (or something similar) error:-
log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable. log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by log4j:ERROR [org.powermock.core.classloader.MockClassLoader@14a55f2] whereas object of type log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [sun.misc.Launcher$AppClassLoader@92e78c]. log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
or
Caused by: org.apache.commons.logging.LogConfigurationException:Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
There are a couple of different solutions to this:
# Upgrade to PowerMock 1.3+
# Make use of the @PowerMockIgnore annotation at the class-level of the test.
For example if using log4j, use `@PowerMockIgnore(“org.apache.log4j.*”)` if using commons logging, use `@PowerMockIgnore(“org.apache.commons.logging.*”)`.
Reference URL :-
http://powermock.googlecode.com/svn-history/r2047/wiki/FAQ.wiki