java - Jolokia - Origin null 不允许调用此代理

标签 java tomcat httprequest javaagents jolokia

{"stacktrace":"java.lang.Exception: Origin null is not allowed to call this agent\n\tat org.jolokia.http.HttpRequestHandler.handleThrowable(HttpRequestHandler.java:242)\n\tat org.jolokia.jvmagent.handler.JolokiaHttpHandler.doHandle(JolokiaHttpHandler.java:243)\n\tat org.jolokia.jvmagent.handler.JolokiaHttpHandler.handle(JolokiaHttpHandler.java:178)\n\tat com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)\n\tat sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)\n\tat com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)\n\tat sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)\n\tat com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)\n\tat sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:748)\n","error_type":"java.lang.Exception","error":"java.lang.Exception : Origin null is not allowed to call this agent","status":403}



当我尝试查询我的“jolokia”代理时出现此错误。
curl  http://localhost:8778/jolokia/list

我已经使用 jolokia 代理启动了我的 java 应用程序 (kibana),如手册 https://jolokia.org/reference/html/agents.html#agents-jvm 中所述。
java -javaagent:agent.jar=port=8778,host=localhost

我可以看到 (ps -aux) 进程在 Java 参数之间使用 jolokia 代理启动。

我还尝试在我的 Tomcat/webapps 中部署 jolokia war。我已经编辑了 user.xml 文件以添加用户 Jolokia,但我得到了相同的结果

我通过谷歌搜索错误得到的唯一结果似乎是第 287 行的 Jolokia 代码,这似乎暗示主机或地址错误,但我正在从 localhost 执行所有操作,这应该是允许的。
https://github.com/rhuss/jolokia/blob/master/agent/core/src/main/java/org/jolokia/http/HttpRequestHandler.java

我错过了一些设置吗?哪个是最好的测试方法?我对 Java 应用程序和 Jolokia 的经验为零。

最佳答案

Jolokia 默认设置为阻止所有 CORS,位于 apache-activemq/webapps/api/WEB-INF/classes/jolokia-access.xml 文件中。

<cors>
 <strict-checking/>
</cors>
您可以通过在**严格检查**之前删除上述配置或添加允许的来源来禁用它。
<cors>
 <!-- Allow cross origin access from www.jolokia.org ... -->
 <allow-origin>http://www.jolokia.org</allow-origin>

 <!-- ... and all servers from jmx4perl.org with any protocol ->
 <allow-origin>*://*.jmx4perl.org</allow-origin>

 <!-- Check for the proper origin on the server side, too -->
 <strict-checking/>
</cors>
更多详情请引用4.1.5. Cross-Origin Resource Sharing (CORS) restrictions

关于java - Jolokia - Origin null 不允许调用此代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58610243/

相关文章:

python - 将超时设置为 Tornado 中的 http 请求

java - 你如何检测 Java 中的 Retina 显示器?

java - 获取父文件的文件夹名称

java - jar 文件不显示(关闭太快)

web-applications - 单个 Tomcat 中的多个应用程序与 tomcat 的多个实例

node.js - NodeJS - 确定目标网站是否使用 HTTP/2

swift - 如何在 Swift 中发送重复的 HTTP 请求?

java - 来自多个包的推土机通用映射(通配符?)

java - MySQL now 方法与时间戳

tomcat - 在 aws apache tomcat 上部署并运行 war 文件