Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jolokia - Origin null is not allowed to call this agent

{"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.

like image 270
dandan Avatar asked Nov 07 '22 12:11

dandan


1 Answers

Jolokia default setting is set to block all CORS, in apache-activemq/webapps/api/WEB-INF/classes/jolokia-access.xml file.

<cors>
 <strict-checking/>
</cors>

You can disable it by removing above config or adding allowed origins before ** strict-checking**.

<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>

For more details please refer 4.1.5. Cross-Origin Resource Sharing (CORS) restrictions

like image 157
Ara Avatar answered Nov 12 '22 15:11

Ara