Thanks Johan again.
As you suspected this results in all kinds of problems.
Using no @PowerMockIgnore results in
org.springframework.beans.factory.BeanDefinitionStoreException:
Unexpected exception parsing XML document from class path resource
[applicationContext.xml]; nested exception is
java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
cannot be cast to javax.xml.parsers.DocumentBuilderFactory
Using
@PowerMockIgnore("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl")
results in
org.springframework.beans.factory.BeanDefinitionStoreException:Unexpected
exception parsing XML document from class path resource
[applicationContext.xml]; nested exception is
java.lang.ClassCastException:com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
cannot be cast to javax.xml.parsers.DocumentBuilderFactory
Using @PowerMockIgnore("javax.xml.*") results in
org.springframework.beans.factory.BeanDefinitionStoreException:
Unexpected exception parsing XML document from class path resource
[applicationContext.xml]; nested exception is java.lang.LinkageError:
loader constraint violation: when resolving method
"javax.xml.parsers.DocumentBuilder.setEntityResolver(Lorg/xml/sax/
EntityResolver;)V" the class loader (instance of org/powermock/core/
classloader/MockClassLoader) of the current class, org/springframework/
beans/factory/xml/DefaultDocumentLoader, and the class loader
(instance of <bootloader>) for resolved class, javax/xml/parsers/
DocumentBuilder, have different Class objects for the type org/xml/sax/
EntityResolver used in the signature
I am back to the drawing board :-(
Sri
On Sep 22, 2:21 am, Johan Haleby <
johan.hal...@gmail.com> wrote:
> You get this error because somewhere in your code an XML framework is
> initialized. This framework tries to instantiate some classes or check for
> resources using reflection and this the context classloader is PowerMock's
> MockClassloader it cannot be found. What you need to do in these situations
> are to make use of the PowerMockIgnore annotation. Unfortunately this can be
> quite complex and lead to other unwanted side-effects. If you feel like the
> test-code is getting too complex you should refactor your code or think of
> another way to perform the test. But you could try out different
> combinations of PowerMockIgnore, e.g. @PowerMockIgnore("javax.xml.*") or
> @PowerMockIgnore("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFa ctoryImpl").
> Tell us how it goes.
>
> /Johan
>
> We ought add this to the FAQ very soon.
>
> On Tue, Sep 21, 2010 at 9:56 PM, Sri Sankaran
> <
srivaths.sanka...@gmail.com>wrote: