Skip to main content

java.lang.NoSuchMethodError in invoking XMLInputFactory.createXMLEventReade

2 replies [Last post]
tanxuqing
Offline
Joined: 2009-02-21
Points: 0

I got the NoSuchMethodError when invoking createXMLEventReader.
stack trace:
java.lang.NoSuchMethodError: com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.getNamespaceContext()Lcom/sun/org/apache/xerces/internal/xni/NamespaceContext;
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.(XMLStreamReaderImpl.java:113)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:278)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:150)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLEventReader(XMLInputFactoryImpl.java:100)
at com.shera.tms.batch.TerminalImporter.getXMLEventReader(TerminalImporter.java:72)
at com.shera.tms.batch.TerminalImporter.doImport(TerminalImporter.java:47)
at com.shera.tms.batch.TerminalImporterTest.doImport(TerminalImporterTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

code snipet:

    protected XMLEventReader getXMLEventReader(Reader r) throws XMLStreamException {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
        factory.setEventAllocator(new RowEventAllocator());
        XMLEventReader reader = factory.createXMLEventReader(r);
        reader = factory.createFilteredReader(reader, new EventFilter() {
            public boolean accept(XMLEvent event) {
                switch (event.getEventType()) {
                case RowEvent.EVENT_TYPE:
                    return true;
                default:
                    return false;
                }
            }
        });

        return reader;
    }

the exception occurred at line "XMLEventReader reader = factory.createXMLEventReader(r);"

but I can run this code with SJSXP

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tanxuqing
Offline
Joined: 2009-02-21
Points: 0

well, I use JDK 1.5.0_12, jaxp 1.4 nightly build jaxp-1_4-20081221

tanxuqing
Offline
Joined: 2009-02-21
Points: 0

oops,
it's because of the classpath order, I put the JRE ahead of the jaxp JARs