Back to LanguageTool Homepage - Privacy - Imprint

Exception in thread "main" java.lang.NoSuchMethodError


(Clare Buckley) #1

Hello,
I’m currently using langTool.check(string) as described in the languageTool wiki.
In one instance I only use isDictionaryBasedSpellingRule to check the string and it runs with no errors, however when I enable all rules I get the error:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.lang3.StringUtils.equalsAny(Ljava/lang/CharSequence;[Ljava/lang/CharSequence;)Z
	at org.languagetool.rules.UppercaseSentenceStartRule.isQuoteStart(UppercaseSentenceStartRule.java:189)
	at org.languagetool.rules.UppercaseSentenceStartRule.match(UppercaseSentenceStartRule.java:98)
	at org.languagetool.rules.TextLevelRule.match(TextLevelRule.java:39)
	at org.languagetool.JLanguageTool$TextCheckCallable.getTextLevelRuleMatches(JLanguageTool.java:1136)
	at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1120)
	at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1084)
	at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:734)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:678)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:654)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:645)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:604)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:588)

I’m using maven with the following dependency to use languageTool:

org.languagetool language-en 4.4

This is my first time using this tool, any help would be greatly appreciated.
Thanks


(Daniel Naber) #2

Could you post the output of mvn dependency:tree? It looks as if the wrong version of Apache commons is used.


(Clare Buckley) #3

[INFO] PoetryGenerator:Generator:jar:0.0.1-SNAPSHOT
[INFO] ± junit:junit:jar:3.8.1:test
[INFO] ± org.mongodb:mongodb-driver-sync:jar:3.8.2:compile
[INFO] | ± org.mongodb:bson:jar:3.8.2:compile
[INFO] | - org.mongodb:mongodb-driver-core:jar:3.8.2:compile
[INFO] ± org.mongodb:mongo-java-driver:jar:3.9.0:compile
[INFO] ± edu.stanford.nlp:stanford-corenlp:jar:3.8.0:compile
[INFO] | ± com.apple:AppleJavaExtensions:jar:1.4:compile
[INFO] | ± de.jollyday:jollyday:jar:0.4.9:compile
[INFO] | | - javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] | ± org.apache.commons:commons-lang3:jar:3.3.1:compile
[INFO] | ± org.apache.lucene:lucene-queryparser:jar:4.10.3:compile
[INFO] | | - org.apache.lucene:lucene-sandbox:jar:4.10.3:compile
[INFO] | ± org.apache.lucene:lucene-analyzers-common:jar:4.10.3:compile
[INFO] | ± org.apache.lucene:lucene-queries:jar:4.10.3:compile
[INFO] | ± org.apache.lucene:lucene-core:jar:4.10.3:compile
[INFO] | ± javax.servlet:javax.servlet-api:jar:3.0.1:compile
[INFO] | ± com.io7m.xom:xom:jar:1.2.10:compile
[INFO] | | ± xml-apis:xml-apis:jar:1.3.03:compile
[INFO] | | ± xerces:xercesImpl:jar:2.8.0:compile
[INFO] | | - xalan:xalan:jar:2.7.0:compile
[INFO] | ± joda-time:joda-time:jar:2.9.4:compile
[INFO] | ± com.googlecode.efficient-java-matrix-library:ejml:jar:0.23:compile
[INFO] | ± org.glassfish:javax.json:jar:1.0.4:compile
[INFO] | - com.google.protobuf:protobuf-java:jar:3.2.0:compile
[INFO] ± edu.stanford.nlp:stanford-corenlp:jar:models:3.8.0:compile
[INFO] ± edu.stanford.nlp:stanford-corenlp:jar:models-english:3.8.0:compile
[INFO] ± edu.stanford.nlp:stanford-parser:jar:3.9.2:compile
[INFO] ± org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] ± org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO] | - log4j:log4j:jar:1.2.17:compile
[INFO] - org.languagetool:language-en:jar:4.4:compile
[INFO] ± org.languagetool:languagetool-core:jar:4.4:compile
[INFO] | ± com.google.guava:guava:jar:21.0:compile
[INFO] | ± net.java.dev.jna:jna:jar:4.4.0:compile
[INFO] | ± org.carrot2:morfologik-fsa:jar:2.1.5:compile
[INFO] | ± org.carrot2:morfologik-fsa-builders:jar:2.1.5:compile
[INFO] | ± org.carrot2:morfologik-speller:jar:2.1.5:compile
[INFO] | ± org.carrot2:morfologik-stemming:jar:2.1.5:compile
[INFO] | ± com.carrotsearch:hppc:jar:0.7.2: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.6:compile
[INFO] | | - net.arnx:jsonic:jar:1.2.11:compile
[INFO] | ± com.intellij:annotations:jar:12.0:compile
[INFO] | ± org.apache.lucene:lucene-backward-codecs:jar:5.5.4:compile
[INFO] | ± edu.berkeley.nlp:berkeleylm:jar:1.1.2:compile
[INFO] | ± com.fasterxml.jackson.core:jackson-databind:jar:2.9.4:compile
[INFO] | | ± com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | | - com.fasterxml.jackson.core:jackson-core:jar:2.9.4:compile
[INFO] | ± javax.measure:unit-api:jar:1.0:compile
[INFO] | ± tech.units:indriya:jar:1.2:compile
[INFO] | | - tech.uom.lib:uom-lib-common:jar:1.1:compile
[INFO] | ± org.glassfish.jaxb:jaxb-runtime:jar:2.3.0:compile
[INFO] | | ± org.glassfish.jaxb:jaxb-core:jar:2.3.0:compile
[INFO] | | | ± org.glassfish.jaxb:txw2:jar:2.3.0:compile
[INFO] | | | - com.sun.istack:istack-commons-runtime:jar:3.0.5:compile
[INFO] | | ± org.jvnet.staxex:stax-ex:jar:1.7.8:compile
[INFO] | | - com.sun.xml.fastinfoset:FastInfoset:jar:1.2.13:compile
[INFO] | ± javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | ± biz.k11i:xgboost-predictor:jar:0.3.0:compile
[INFO] | | - net.jafama:jafama:jar:2.1.0:runtime
[INFO] | - org.apache.commons:commons-csv:jar:1.6:compile
[INFO] ± org.apache.opennlp:opennlp-tools:jar:1.7.2: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: 12.024 s
[INFO] Finished at: 2019-01-31T18:17:44Z
[INFO] ------------------------------------------------------------------------


(Daniel Naber) #4

This line is the problem. I’m not sure why you get version 3.3.1, but you need at least 3.5. Maven here resolves the version to 3.8.1. Maybe it makes a difference if you add languagetool-core as a dependency.


(Clare Buckley) #5

I’ve added the dependency

> 	<dependency>
> 			<groupId>org.languagetool</groupId>
> 			<artifactId>languagetool-core</artifactId>
> 			<version>4.4</version>
> 		</dependency>

But still get the same error when running the code

Running mvn dependency:tree still contains org.apache.commons:commons-lang3:jar:3.3.1:compile

Whole output:

[INFO] PoetryGenerator:Generator:jar:0.0.1-SNAPSHOT
[INFO] ± junit:junit:jar:3.8.1:test
[INFO] ± org.mongodb:mongodb-driver-sync:jar:3.8.2:compile
[INFO] | ± org.mongodb:bson:jar:3.8.2:compile
[INFO] | - org.mongodb:mongodb-driver-core:jar:3.8.2:compile
[INFO] ± org.mongodb:mongo-java-driver:jar:3.9.0:compile
[INFO] ± edu.stanford.nlp:stanford-corenlp:jar:3.8.0:compile
[INFO] | ± com.apple:AppleJavaExtensions:jar:1.4:compile
[INFO] | ± de.jollyday:jollyday:jar:0.4.9:compile
[INFO] | ± org.apache.commons:commons-lang3:jar:3.3.1:compile
[INFO] | ± org.apache.lucene:lucene-queryparser:jar:4.10.3:compile
[INFO] | | - org.apache.lucene:lucene-sandbox:jar:4.10.3:compile
[INFO] | ± org.apache.lucene:lucene-analyzers-common:jar:4.10.3:compile
[INFO] | ± org.apache.lucene:lucene-queries:jar:4.10.3:compile
[INFO] | ± org.apache.lucene:lucene-core:jar:4.10.3:compile
[INFO] | ± javax.servlet:javax.servlet-api:jar:3.0.1:compile
[INFO] | ± com.io7m.xom:xom:jar:1.2.10:compile
[INFO] | | ± xml-apis:xml-apis:jar:1.3.03:compile
[INFO] | | ± xerces:xercesImpl:jar:2.8.0:compile
[INFO] | | - xalan:xalan:jar:2.7.0:compile
[INFO] | ± joda-time:joda-time:jar:2.9.4:compile
[INFO] | ± com.googlecode.efficient-java-matrix-library:ejml:jar:0.23:compile
[INFO] | ± org.glassfish:javax.json:jar:1.0.4:compile
[INFO] | - com.google.protobuf:protobuf-java:jar:3.2.0:compile
[INFO] ± edu.stanford.nlp:stanford-corenlp:jar:models:3.8.0:compile
[INFO] ± edu.stanford.nlp:stanford-corenlp:jar:models-english:3.8.0:compile
[INFO] ± edu.stanford.nlp:stanford-parser:jar:3.9.2:compile
[INFO] ± org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] ± org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO] | - log4j:log4j:jar:1.2.17:compile
[INFO] ± org.languagetool:language-en:jar:4.4:compile
[INFO] | ± org.apache.opennlp:opennlp-tools:jar:1.7.2: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] - org.languagetool:languagetool-core:jar:4.4:compile
[INFO] ± com.google.guava:guava:jar:21.0:compile
[INFO] ± net.java.dev.jna:jna:jar:4.4.0:compile
[INFO] ± org.carrot2:morfologik-fsa:jar:2.1.5:compile
[INFO] ± org.carrot2:morfologik-fsa-builders:jar:2.1.5:compile
[INFO] ± org.carrot2:morfologik-speller:jar:2.1.5:compile
[INFO] ± org.carrot2:morfologik-stemming:jar:2.1.5:compile
[INFO] ± com.carrotsearch:hppc:jar:0.7.2: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.6:compile
[INFO] | - net.arnx:jsonic:jar:1.2.11:compile
[INFO] ± com.intellij:annotations:jar:12.0:compile
[INFO] ± org.apache.lucene:lucene-backward-codecs:jar:5.5.4:compile
[INFO] ± edu.berkeley.nlp:berkeleylm:jar:1.1.2:compile
[INFO] ± com.fasterxml.jackson.core:jackson-databind:jar:2.9.4:compile
[INFO] | ± com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | - com.fasterxml.jackson.core:jackson-core:jar:2.9.4:compile
[INFO] ± javax.measure:unit-api:jar:1.0:compile
[INFO] ± tech.units:indriya:jar:1.2:compile
[INFO] | - tech.uom.lib:uom-lib-common:jar:1.1:compile
[INFO] ± javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] ± org.glassfish.jaxb:jaxb-runtime:jar:2.3.0:compile
[INFO] | ± org.glassfish.jaxb:jaxb-core:jar:2.3.0:compile
[INFO] | | ± org.glassfish.jaxb:txw2:jar:2.3.0:compile
[INFO] | | - com.sun.istack:istack-commons-runtime:jar:3.0.5:compile
[INFO] | ± org.jvnet.staxex:stax-ex:jar:1.7.8:compile
[INFO] | - com.sun.xml.fastinfoset:FastInfoset:jar:1.2.13:compile
[INFO] ± javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] ± biz.k11i:xgboost-predictor:jar:0.3.0:compile
[INFO] | - net.jafama:jafama:jar:2.1.0:runtime
[INFO] - org.apache.commons:commons-csv:jar:1.6:compile


(Clare Buckley) #6

I added the dependency

org.apache.commons commons-lang3 3.5

as well as the dependency you suggested and that seems to have fixed the error.

Many thanks for your help.