You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Kilian Evang <KE...@de.ibm.com> on 2007/08/28 17:54:21 UTC

Mysterious NoSuchMethodError: XMLSchemaLoader.loadGrammar(XMLInputSource)

Hi everybody,

I'm new to Xerces. Today I added xercesImpl.jar and the other jars to my 
Eclipse build path to validate an XML document against an XML schema in my 
application. But when I call newSchema() on a Schema instance, I get:

Exception in thread "main" java.lang.NoSuchMethodError: 
org.apache.xerces.impl.xs.XMLSchemaLoader: method 
loadGrammar([Lorg/apache/xerces/xni/parser/XMLInputSource;)V not found
                 at 
org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown 
Source)
                 at javax.xml.validation.SchemaFactory.newSchema(Unknown 
Source)
                 at javax.xml.validation.SchemaFactory.newSchema(Unknown 
Source)
                 at 
org.apache.uima.uima4jcr.RepositoryAnnotationService.<init>(RepositoryAnnotationService.java:80)
                 at 
org.apache.uima.uima4jcr.clt.JackHat.main(JackHat.java:80)

Inspecting xercesImpl.jar, I find that the method it doesn't find is 
actually there in the XMLSchemaLoader class.

Any ideas?

Thanks
- Kilian

Re: Mysterious NoSuchMethodError: XMLSchemaLoader.loadGrammar(XMLInputSource)

Posted by Kilian Evang <KE...@de.ibm.com>.
That does the job. Thanks a lot!

Kilian Evang
Intern 
  
Mail: kevang@de.ibm.com
  
IBM Deutschland Entwicklung GmbH
Schoenaicher Str. 220
D-71032 Boeblingen
Germany
Dept. D3229 -- Room 06-119 
  
IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



Re: Mysterious NoSuchMethodError: XMLSchemaLoader.loadGrammar(XMLInputSource)

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Kilian,

Most likely it's picking up a mix of classes from xercesImpl.jar and the
version of Xerces in whatever JDK you're using which are incompatible with
each other. If you're using JDK 1.4 or above you should be using the
"Endorsed Standards Override Mechanism" [1][2]. If you merely put the jars
on the classpath you can end up with a hybrid mess where some of the API
and implementation get loaded from the JDK and other parts get loaded from
the jars.

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-4
[2] http://java.sun.com/j2se/1.4.2/docs/guide/standards/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Kilian Evang <KE...@de.ibm.com> wrote on 08/28/2007 11:54:21 AM:

> Hi everybody,
>
> I'm new to Xerces. Today I added xercesImpl.jar and the other jars
> to my Eclipse build path to validate an XML document against an XML
> schema in my application. But when I call newSchema() on a Schema
> instance, I get:
>
> Exception in thread "main" java.lang.NoSuchMethodError: org.apache.
> xerces.impl.xs.XMLSchemaLoader: method
> loadGrammar([Lorg/apache/xerces/xni/parser/XMLInputSource;)V not found
>                 at org.apache.xerces.jaxp.validation.
> XMLSchemaFactory.newSchema(Unknown Source)
>                 at javax.xml.validation.SchemaFactory.
> newSchema(Unknown Source)
>                 at javax.xml.validation.SchemaFactory.
> newSchema(Unknown Source)
>                 at org.apache.uima.uima4jcr.
> RepositoryAnnotationService.<init>(RepositoryAnnotationService.java:80)
>                 at
org.apache.uima.uima4jcr.clt.JackHat.main(JackHat.java:80)
>
> Inspecting xercesImpl.jar, I find that the method it doesn't find is
> actually there in the XMLSchemaLoader class.
>
> Any ideas?
>
> Thanks
> - Kilian


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org