Back to LanguageTool Homepage - Privacy - Imprint

How to enable LanguageTool Server locally

Purpose : Instead of pointing to languagetool.org, I’d love to setup a Language Server locally to run a HTML document against.
The HTML document comes with this specific line of code:
///////////////////////////////////

/* The URL of your LanguageTool server.
If you use your own server here and it’s not running on the same domain
as the text form, make sure the server gets started with ‘–allow-origin …’
and use ‘https://your-server/v2/check’ as URL: */
languagetool_rpc_url : "http://localhost:8081/v2/check?",

//////////////////////////////////

Problem statement : Fail to make LanguageTool work, because after issuing this command : java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8081

the Prompt throw errors as follows:
//
Server started
2017-12-13 08:24:35 An error has occurred, sending HTTP code 500. Access from 127.0.0.1, HTTP user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36, language: en-US, text length: 43, Stacktrace follows:
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.languagetool.server.TextChecker.checkText(TextChecker.java:127)
at org.languagetool.server.ApiV2.handleRequest(ApiV2.java:60)
at org.languagetool.server.LanguageToolHttpHandler.handle(LanguageToolHttpHandler.java:101)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.languagetool.rules.CleanOverlappingFilter.getMatchPriority(CleanOverlappingFilter.java:89)
at org.languagetool.rules.CleanOverlappingFilter.filter(CleanOverlappingFilter.java:63)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:548)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:492)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:480)
at org.languagetool.server.TextChecker.getRuleMatches(TextChecker.java:200)
at org.languagetool.server.TextChecker.access$000(TextChecker.java:43)
at org.languagetool.server.TextChecker$1.call(TextChecker.java:121)
at org.languagetool.server.TextChecker$1.call(TextChecker.java:114)
at java.util.concurrent.FutureTask.run(Unknown Source)
/
/
Meanwhile, When checking the HTML document, I find out that the HTML document highlights this error message that follows:

Summary

Error: Did not get response from service. Please try again in one minute.

Thanks for the report. Does this happen without you sending any text to the server? If not, could you share the text you’re sending? Are you using LT 3.9?

I work with LT 3.8 , Here you go :

Could you see if this also happens with LT 3.9? There’s a place in the code that can indeed cause this issue and I have just fixed it. The fix will be part of tomorrow’s snapshot at: https://languagetool.org/download/snapshots/?C=M;O=D

thank you for the pointer Daniel, I will give it a try later.

Even with the latest LT 3.9 installed ,


The same problem occurs:

But this should fix it, doesn’t it? https://languagetool.org/download/snapshots/LanguageTool-20171219-snapshot.zip

The same problem occurred again as shown:

This is a different issue now, as the server doesn’t print any error. Please try starting the server with --allow-origin '*' as an additional parameter. This is probably a CORS issue - the browser has loaded the file from a file: URL and thus the Javascript cannot access the server running on localhost.

--allow-origin takes a parameter, please see my previous reply.

i did exactly append --allow-origin ‘*’ to the command line, but the problem remains.

Maybe it works differently under Windows and you need to use -allow-origin * (without the quotes around *), but I cannot test that now.

Apply “*”, it works perfectly well! Thanks a million Daniel.