Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAX2 parsing - com.sun.org.apache.xerces.internal.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader #290

Closed
johanhaleby opened this issue Jul 24, 2015 · 2 comments

Comments

@johanhaleby
Copy link
Collaborator

From AlexWib...@gmail.com on July 28, 2010 08:58:48

Hi all,

First of all, my problem is probably similar to the following issue: http://groups.google.com/group/powermock/browse_thread/thread/88079512f2dfcbd1/59b5d831e3e7f9b8?pli=1 basically, I have a hibernate configuration that gets loaded in my test.
I'm getting the following error:


java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:199)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:150)
at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
at org.dom4j.io.SAXReader.read(SAXReader.java:435)

org.hibernate.HibernateException: Could not parse configuration: inMemory-hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)
...
..
Caused by: org.dom4j.DocumentException: SAX2 driver class com.sun.org.apache.xerces.internal.parsers.SAXParser does not implement XMLReader Nested exception: SAX2 driver class com.sun.org.apache.xerces.internal.parsers.SAXParser does not implement XMLReader
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
... 34 more

at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)

Warning: Caught exception attempting to use SAX to load a SAX XMLReader
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64)
Warning: Exception was: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
Warning: I will print the stack trace then carry on using the default SAX parser
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)
...
..

I've tried the recommendation suggested in the issue I mentioned above, without any luck:


@RunWith(PowerMockRunner.class)
@PrepareForTest({MyServiceImpl.class})
@PowerMockIgnore( { "com.sun.org.apache.xerces.", "org.dom4j.", "org.xml.sax.*" })
public class MyTest extends InMemoryLookupTests{

private MyServiceImpl service;
...

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    service = new MyServiceImpl();
    ....
}

.....

}


Could someone please share some light?

Thanks in advance!

Regards,

Alex.

Original issue: http://code.google.com/p/powermock/issues/detail?id=270

@johanhaleby
Copy link
Collaborator Author

From AlexWib...@gmail.com on July 28, 2010 00:00:28

Sorry... i should have posted this in mailing list.. how can I close this??

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on October 15, 2010 12:23:59

Status: Invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant