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:
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.
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.
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.
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.