【问题标题】:How do I fix java.lang.RuntimeException?如何修复 java.lang.RuntimeException?
【发布时间】:2011-04-20 09:13:46
【问题描述】:

我正在尝试使用LanguageTool。 这是在使用信息中:

> Using LanguageTool from other
> applications:    Start the stand-alone
> application and configure it to listen
> on a port that is not used yet (the
> default port, 8081, should often be
> okay). This way LanguageTool will run
> in server mode until you stop it. The
> client that wants to use LanguageTool
> can now just send its text to this
> URL:
> http://localhost:8081/?language=xx&text=my+text

我正在尝试使用我的 IP http://<IP HERE>:8081/?language=xx&text=my+text,但我不断得到

错误:java.lang.RuntimeException:错误:来自(IP 地址)的访问被拒绝

我做错了什么,我该如何解决?

【问题讨论】:

  • 这个模式可能只允许从本地地址访问,所以需要使用localhost或者127.0.0.1作为地址。
  • 我可能需要从另一台计算机访问它。有没有办法做到这一点?
  • 您是否尝试过按照建议使用 localhost(即 127.0.0.1)?
  • 查看the code 表明此限制是硬编码的。你可能想要修补它。
  • @Ingo:太好了。 @Joachim:我明白了,谢谢! :)

标签: java languagetool


【解决方案1】:

仅接受来自本地网络地址(即环回设备)的连接的限制是硬编码的:LanguageToolHttpHandler

如果你想改变它,你必须改变源。

【讨论】:

  • 更新:从 LanguageTool 1.7 开始,有一个构造函数允许您指定哪些 IP 可以访问。对于命令行版本,您可以设置--public 参数以允许从任何地方访问(免责声明:我是LanguageTool 维护者)。
猜你喜欢
  • 1970-01-01
  • 2020-10-15
  • 1970-01-01
  • 1970-01-01
  • 2018-11-13
  • 2021-06-22
  • 2018-04-24
  • 1970-01-01
相关资源
最近更新 更多