java Jetty 返回 403 Forbidden

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15142962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 18:38:21  来源:igfitidea点击:

Jetty returning 403 Forbidden

javajetty

提问by subodh

Hi I am porting my web app from tomcat to Jetty. I am using the Jetty runner to launch it. I am using the following command to launch Jetty:

嗨,我正在将我的 Web 应用程序从 tomcat 移植到 Jetty。我正在使用 Jetty runner 来启动它。我正在使用以下命令启动 Jetty:

java -jar jetty-runner.jar --port --path url-path path-to-war

java -jar jetty-runner.jar --port --path url-path path-to-war

However when I try to browse to the from the browser I get the following error:

但是,当我尝试从浏览器浏览时,出现以下错误:

HTTP ERROR 403

Problem accessing . Reason:

Forbidden

HTTP 错误 403

访问问题。原因:

Forbidden

In the logs i see the following Warning:

在日志中,我看到以下警告:

WARN:oejs.SecurityHandler:No authenticator for: {RoleInfo,C[*, all_auth_users]}

警告:oejs.SecurityHandler:无身份验证器:{RoleInfo,C[*, all_auth_users]}

I am trying to use Jetty out of the box and haven't customized any config anywhere. Is there any additional configuration required to make this work?

我正在尝试开箱即用地使用 Jetty,并且没有在任何地方自定义任何配置。是否需要任何额外的配置来完成这项工作?

回答by Joakim Erdfelt

Likely cause: your war/webapp has security constraints defined, but you haven't specified what authentication type to use on the server side.

可能的原因:您的 war/webapp 已定义安全约束,但您尚未指定在服务器端使用的身份验证类型。

Either:

任何一个:

  • Remove your <security-constraint>in your war/webapp WEB-INF/web.xmlfile. or..
  • Add an Authentication scheme on the server side. Look at etc/jetty-testrealm.xmlfor an example using the HashLoginService authenticator.
  • <security-constraint>在你的 war/webappWEB-INF/web.xml文件中删除你的。或者..
  • 在服务器端添加身份验证方案。查看etc/jetty-testrealm.xml使用 HashLoginService 身份验证器的示例。

回答by user2280949

In my case I forget that paste the index.html example page. Its all.

就我而言,我忘记粘贴 index.html 示例页面。它的全部。