Reputation: 131
{"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.
Upvotes: 7
Views: 6779
Reputation: 2575
Jolokia's default setting will block all 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>
Just remove the <strict-checking/>
tag from the above default configuration in jolokia-access.xml
Upvotes: 0
Reputation: 154
Depending on your current configuration need to be changed. Based on your exact error line, you need to add "Origin" header in your http request.
For example -
curl http://localhost:8778/jolokia/list -H "Origin:http://localhost"
Remember, if you have default CORS is enabled, add exception with <allow-origin>
under <cors>
tag.
Upvotes: 3
Reputation: 83
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
Upvotes: 3