Skip to main content

java.lang.NoSuchMethodError

9 replies [Last post]
petras
Offline
Joined: 2007-07-31
Points: 0

I am using JAXP 1.4.2 but this code:

XMLInputFactory factory = XMLInputFactory.newInstance();
XMLStreamReader parser = factory.createXMLStreamReader(this.input);

throws 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:98)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:267)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:160)
at eu.ysoft.sqrs.communicator.protocols.xml.XMLMessageParser.retrieve(XMLMessageParser.java:53)

What is wrong?
Thanks for reply

Petras

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
techiesaf
Offline
Joined: 2008-08-14
Points: 0

Just wanted to point out that we need to set the endorsed folder in the jre/lib folder of the jdk you are using.. coz i tried putting it in /lib folder which was pointing to my JDK and it didnt work - so after i put it in jre/lib folder it worked... so FYI...

carlosgg
Offline
Joined: 2004-07-23
Points: 0

It is working!!

At first, after copying the libraries in the endorsed folder of the JDK I got the following error:

16:16:41,376 FATAL [application] javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
javax.faces.el.EvaluationException: javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
...

This is a different error, and it was produced by the Stax-api.jar JBoss library. Then I notice that the JBoss also has an "endorsed" folder, so I copied the libraries there too and now, finally, it is working.

Thank you very much for your help.

Carlos.

joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Carlos,

That's great! Glad it worked for you.

I am not familiar with JBoss. From the messages you're getting, it looked like JBoss has bundled it's own Stax impl among other parsers. It's nice it provides similiar mechnism for you to override it. There were instructions on how to use jdk/jaxp instead of its own parsers, but it's for jaxp 1.3. Not sure if it'd work for you (plus, you've found your solution, why care :)

Anyway, here's link: http://wiki.jboss.org/wiki/Wiki.jsp?page=HowToUseJAXP13WithJBoss

Regards,
Joe

petras
Offline
Joined: 2007-07-31
Points: 0

I have forgot write my JDK version.
I am using as carlosgg JDK5 and I have to use this version of JDK.

Petras

gan_sub23
Offline
Joined: 2005-01-28
Points: 0

Well!, the problem is because of the JDK and JAXP versions you are using. JDK 5 has a production version of JAXP 1.3 built into it and the XMLDocumentScannerImpl class included does not contain the method getNamespaceContext(). While the class XMLDocumentScannerImpl included in JAXP 1.4.2 contains this method.

So the simplest way, if your project permits it, is to use JDK 6.0, which has production version of JAXP 1.4 built into it.

-- Ganesh

carlosgg
Offline
Joined: 2004-07-23
Points: 0

Thank you Ganesh.

I agree with you that the simpliest way is to use the JDK 6.0, in fact is wat we are doing in order to be able to progress in the project, but we will need it to work with Java 5.

Is there any way to override the classes that Java5 uses with those in the JAXP 1.4 library?

..:: Carlos ::..

joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Carlos,

Using the Endorsed Standards Override Mechanism, put the JAXP 1.4 jars into /lib/endorsed directory, or set java.endorsed.dirs system property to point to the directory where the JAXP jars reside.

Joe

carlosgg
Offline
Joined: 2004-07-23
Points: 0

Thank you joehw.

I did it in the past and it didn't work, but I'm not sure if I did it right. I will try again and will tell you what the results are.

Carlos.

carlosgg
Offline
Joined: 2004-07-23
Points: 0

I'm having exactly the same problem.

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:99)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:264)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:136)

My configuration is JAXP 1.4.2 in a JBoss 4.2.0 over Java 5.

If I use Java 6 everything works fine, but I need it to work with Java 5.

Carlos.