Back to LanguageTool Homepage - Privacy - Imprint

Issues with Maven and javax.xml.parsers.SAXParserFactory.setSchema

Hello all,

I have a project where I am using languagetool version 3.2. It is a Java 8 project. I can run an unit test from it and it is all good. The name of the project is LanguageCorrectionTool.

I then have this LanguageCorrectionTool as a dependency of another project.

If I issue a “mvn dependency:tree” I do not see any xerces dependency.

This project is also java 8.

However, when I try to call the LanguageCorrectionTool class from my unit test I got the following exception:

Caused by: java.lang.UnsupportedOperationException: This parser does not support specification “null” version “null”
at javax.xml.parsers.SAXParserFactory.setSchema(
at org.languagetool.tokenizers.SrxTools.createSrxDocument(
at org.languagetool.tokenizers.LocalSRXSentenceTokenizer.(
at org.languagetool.tokenizers.SimpleSentenceTokenizer.(
at org.languagetool.Language.(
… 29 more

I have, in some of my dependencies, exclusions such as:

xalan xalan xerces xerces xercesImpl xerces xmlParserAPIs xerces jaxp-api javax.xml.parsers

And that still does not work.

My maven and java version is as follows:

Maven home: /usr/local/apache-maven/default-maven
Java version: 1.8.0_72, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: “linux”, version: “3.19.0-49-generic”, arch: “amd64”, family: “unix”

Thank you,


Hi, I suggest you look through all the *.jar files that you have as dependencies and see which one has SAXParserFactoryImpl - this should probably be removed, as SAXParserFactoryImpl is part of Java 8.


That seems to be solved. I now have a problem with the morfologik dictionary even thought it is on the classpath.

The issue is the following: I have a project calls LanguageCorrectionTool which works well even its unit tests.

The maven dependency tree of it is as follows:

[INFO] ------------------------------------------------------------------------
[INFO] Building LanguageCorrectionTool 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] — maven-dependency-plugin:2.8:tree (default-cli) @ LanguageCorrectionTool —
[INFO] nando.language:LanguageCorrectionTool:jar:1.0.0
[INFO] ± junit:junit:jar:4.11:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] ± org.languagetool:languagetool-core:jar:3.2:compile
[INFO] | ± commons-lang:commons-lang:jar:2.6:compile
[INFO] | ±
[INFO] | ± org.carrot2:morfologik-fsa:jar:1.10.0:compile
[INFO] | ± org.carrot2:morfologik-speller:jar:1.10.0:compile
[INFO] | ± org.carrot2:morfologik-stemming:jar:1.10.0:compile
[INFO] | ± com.carrotsearch:hppc:jar:0.6.1:compile
[INFO] | ± net.loomchild:segment:jar:2.0.0:compile
[INFO] | | - commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | ± com.optimaize.languagedetector:language-detector:jar:0.5:compile
[INFO] | | ± net.arnx:jsonic:jar:1.2.11:compile
[INFO] | | ±
[INFO] | | - org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] | ± com.intellij:annotations:jar:12.0:compile
[INFO] | ± org.apache.lucene:lucene-core:jar:5.2.1:compile
[INFO] | ± org.apache.lucene:lucene-backward-codecs:jar:5.2.1:compile
[INFO] | - edu.berkeley.nlp:berkeleylm:jar:1.1.2:compile
[INFO] - org.languagetool:language-en:jar:3.2:compile
[INFO] ± org.apache.opennlp:opennlp-tools:jar:1.6.0:compile
[INFO] ± edu.washington.cs.knowitall:opennlp-tokenize-models:jar:1.5:compile
[INFO] ± edu.washington.cs.knowitall:opennlp-postag-models:jar:1.5:compile
[INFO] - edu.washington.cs.knowitall:opennlp-chunk-models:jar:1.5:compile
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.638 s
[INFO] Finished at: 2016-02-03T21:08:19-07:00
[INFO] Final Memory: 17M/619M
[INFO] ------------------------------------------------------------------------

Now, I have another application that uses LanguageCorrectionTool as a dependency.

When I run the unit tests from the second application I get the following:

java.lang.NoSuchMethodError: morfologik.stemming.DictionaryMetadata.isFrequencyIncluded()Z
at org.languagetool.tagging.MorfologikTagger.tag(
at org.languagetool.tagging.CombiningTagger.tag(
at org.languagetool.tagging.BaseTagger.getAnalyzedTokens(
at org.languagetool.tagging.BaseTagger.tag(
at org.languagetool.JLanguageTool.getRawAnalyzedSentence(
at org.languagetool.JLanguageTool.getAnalyzedSentence(
at org.languagetool.JLanguageTool.analyzeSentences(
at org.languagetool.JLanguageTool.check(
at org.languagetool.JLanguageTool.check(
at org.languagetool.JLanguageTool.check(
at nando.language.LanguageCorrection.correctDictionaryOnly(
at nando.language.LanguageCorrection.correct(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
at org.junit.runners.model.FrameworkMethod.invokeExplosively(
at org.junit.internal.runners.statements.InvokeMethod.evaluate(
at org.junit.internal.runners.statements.RunBefores.evaluate(
at org.junit.internal.runners.statements.RunAfters.evaluate(
at org.junit.runners.ParentRunner.runLeaf(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.ParentRunner$
at org.junit.runners.ParentRunner$1.schedule(
at org.junit.runners.ParentRunner.runChildren(
at org.junit.runners.ParentRunner.access$000(
at org.junit.runners.ParentRunner$2.evaluate(
at org.junit.internal.runners.statements.RunBefores.evaluate(
at org.junit.internal.runners.statements.RunAfters.evaluate(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

As you can see it cannot see the dependency, the method is there as I saw it looking under my .m2 repostiory folder. Not sure what is the issue now if the LanguageCorrectionTool is on the classpath, etc. All of them are Java8 projects.


Funny thing, though, inspecting with Eclipse debugger.

I can see the morfologik.stemming.Dictionary being created properly etc. The issue is that the method isFrequencyIncluded() does not exist which is why the system fails. However, looking at the source code used by LanguageTool 3.2, which is morfologik-stemming 1.10.0 the method is there inside morfologik.stemming.Dictionary.

Therefore, I am not sure what is going on here. Seems that a different version of it is being loaded which does not make much sense as that is the only one as per the maven depdency tree.

Maybe there’s an old JAR around on the classpath (not from Maven, or from old runs)? Also, did you run mvn clean?

Yes Dnaber. Off course ran mvn clean:clean. Interesting stuff.

From the first JAR, all works just fine. It is the second JAR that uses the first and issues the exceptions. Both are 1.8. I had checked the deptree of both. I guess a little more playing with it.