Back to LanguageTool Homepage - Privacy - Imprint

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


(Carlos A) #1

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(SAXParserFactory.java:394)
at net.sourceforge.segment.srx.io.Srx2SaxParser.(Srx2SaxParser.java:181)
at org.languagetool.tokenizers.SrxTools.createSrxDocument(SrxTools.java:51)
at org.languagetool.tokenizers.LocalSRXSentenceTokenizer.(LocalSRXSentenceTokenizer.java:46)
at org.languagetool.tokenizers.SimpleSentenceTokenizer.(SimpleSentenceTokenizer.java:37)
at org.languagetool.Language.(Language.java:63)
... 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,

Carlos.


(Daniel Naber) #2

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.


(Carlos A) #3

Dnaber,

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]
[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] | +- net.java.dev.jna:jna:jar:4.1.0:compile
[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] | | +- com.google.guava:guava:jar:16.0.1:compile
[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] BUILD SUCCESS
[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(MorfologikTagger.java:68)
at org.languagetool.tagging.CombiningTagger.tag(CombiningTagger.java:59)
at org.languagetool.tagging.BaseTagger.getAnalyzedTokens(BaseTagger.java:165)
at org.languagetool.tagging.BaseTagger.tag(BaseTagger.java:145)
at org.languagetool.JLanguageTool.getRawAnalyzedSentence(JLanguageTool.java:720)
at org.languagetool.JLanguageTool.getAnalyzedSentence(JLanguageTool.java:701)
at org.languagetool.JLanguageTool.analyzeSentences(JLanguageTool.java:521)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:497)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:450)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:446)
at nando.language.LanguageCorrection.correctDictionaryOnly(LanguageCorrection.java:123)
at nando.language.LanguageCorrection.correct(LanguageCorrection.java:223)
at nando.nlp.tools.SpellingTools.correctText(SpellingTools.java:44)
at nando.nlp.tools.TestSpellingTools.testCorrectText(TestSpellingTools.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

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.

Thanks.


(Carlos A) #4

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.


(Daniel Naber) #5

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


(Carlos A) #6

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


(Carlos A) #7

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.