Wolfgang Fahl
Wolfgang Fahl

Reputation: 15776

Languagetool example: java.lang.NoSuchMethodError: org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar

The error message java.lang.NoSuchMethodError: org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar shows up when I try to run the example from

http://wiki.languagetool.org/java-api

JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
langTool.activateDefaultPatternRules();
List<RuleMatch> matches = langTool.check("A sentence " +
    "with a error in the Hitchhiker's Guide tot he Galaxy");

for (RuleMatch match : matches) {
  System.out.println("Potential error at line " +
      match.getLine() + ", column " +
      match.getColumn() + ": " + match.getMessage());
  System.out.println("Suggested correction: " +
      match.getSuggestedReplacements());
}

the solution offered in: java.lang.NoSuchMethodError: org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar

would mean that the Xerces specified in LanguageTools dependency would be the one creating the trouble.

mvn dependency:tree | grep -i xerces

does not show any result and in Languagetools pom.xml Xerces is explicitly excluded.

my own test project has the following xerces dependencies:

mvn dependency:tree | grep -i xerces
[INFO] |  |  |  |  +- org.bluestemsoftware.open.maven.tparty:xerces-impl:jar:2.9.0:compile
[INFO] |  |  |  |  \- xerces:xercesImpl:jar:2.6.2:compile

I assume I have do get rid of one of these dependencies, change the order of dependencies or add the correct xerces dependency for LanguageTool. What would be the right approach - one of these or something else?

Upvotes: 0

Views: 1938

Answers (1)

Veeramani Natarajan
Veeramani Natarajan

Reputation: 51

According to oracle documents This Error is

Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

Upvotes: 1

Related Questions