tomcat Jolokia -不允许呼叫此座席的起始空值

pwuypxnk  于 2023-03-18  发布在  其他
关注(0)|答案(3)|浏览(184)

{"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}
I get this error when I try to query my "jolokia" agent.

curl  http://localhost:8778/jolokia/list

I've launched my java application (kibana) with the jolokia agent, as explained in the Manual https://jolokia.org/reference/html/agents.html#agents-jvm.

java -javaagent:agent.jar=port=8778,host=localhost

I can see (ps -aux) that the process launched with the jolokia agent in between the Java Arguments.
I have also tried to deploy the jolokia war in my Tomcat /webapps. I've edited the user.xml file to add the User Jolokia, but I get the same result
The only result I get by googling the error seems to be the Jolokia code, at line 287, which seems to imply the host or address are wrong, but i'm doing everything from localhost, which should be allowed. https://github.com/rhuss/jolokia/blob/master/agent/core/src/main/java/org/jolokia/http/HttpRequestHandler.java
Am I missing some settings? which is the best way to test it? I have zero experience with Java applications and Jolokia.

wtzytmuj

wtzytmuj1#

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

<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

clj7thdc

clj7thdc2#

根据您当前的配置需要更改。根据您的确切错误行,您需要在您的http请求中添加“起源”标头。
例如-curl http://localhost:8778/jolokia/list -H "Origin:http://localhost"
请记住,如果启用了默认CORS,请在<cors>标记下添加<allow-origin>例外。

lf5gs5x2

lf5gs5x23#

Jolokia的默认设置将阻止所有CORS

<cors>
        <!-- Allow cross origin access from localhost ... -->
        <allow-origin>*://localhost*</allow-origin>

        <!-- Options from this point on are auto-generated by Create.java from the Artemis CLI -->
        <!-- Check for the proper origin on the server side, too -->
        <strict-checking/>
    </cors>

</restrict>

只需从jolokia-access.xml中的上述默认配置中删除<strict-checking/>标记

相关问题