Java API - German Error

Hi,

I’m using the Java API to check some texts.
I get the list of available languages with: Languages.get() and I initialize the JLanguageTool object with the language I want from the list to then call the .check(text) function.

This works perfectly for all languages, but it doesn’t work for German or any variation of German (German, German (Germany), German (Austria), German (Swiss), Simple German).

This is the error I get:
nested exception is java.lang.NoClassDefFoundError: org/apache/commons/lang3/RegExUtils] with root cause
java.lang.NoClassDefFoundError: org/apache/commons/lang3/RegExUtils
at org.languagetool.tagging.de.GermanTagger.tag(GermanTagger.java:179)
at org.languagetool.tagging.de.GermanTagger.lookup(GermanTagger.java:116)
at org.languagetool.rules.de.CaseRule.match(CaseRule.java:862)
at org.languagetool.JLanguageTool.checkAnalyzedSentence(JLanguageTool.java:814)
at org.languagetool.JLanguageTool$TextCheckCallable.getOtherRuleMatches(JLanguageTool.java:1255)
at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1189)
at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1152)
at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:782)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:726)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:702)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:693)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:652)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:636)

Could you please assist?

Thank you very much!
Marta

Do you use Maven or Gradle, as documented at Java API - LanguageTool Wiki? The commons-lang3 JAR file seems to be missing in your class path.

Hi Daniel,

thanks for your response.
I am using Maven, and I included the dependency in the pom.xml as said in the page you mentioned.
I checked the JAR files and I have the commons-lang-2.6.jar and the commons-lang3-3.5.jar, does it have to be the commons-lang3.jar file, not the 3-3.5?
But this would make it fail for any language, wouldn’t it? Not just for German.

Thanks!

You could call mvn dependency:tree to see how dependencies are resolved. The version used by LT is 3.8.1, earlier version might not work.

1 Like

Hi Daniel,

I added the dependency for the last available version of commons-lang3, and now it’s working!

< groupId >org.apache.commons</ groupId >
< artifactId >commons-lang3</ artifactId >
< version >3.9</ version >

Thanks for your help,
Marta