Elastic APM Agent Access Denied with AccessControlException

1.4k Views Asked by At

I am implementing apm agent to sonarqube and I can connect to apm server using curl

curl -v "" returns 200

Command:

sudo java -jar apm-agent-attach-standalone.jar --include '.sonar.' ---config config_file=elasticapm.properties

Command output:

It shows agent as attached

Logfile:

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
        at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
        at java.base/java.security.AccessController.checkPermission(AccessController.java:897)
        at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:322)
        at java.base/java.lang.Class.forName(Class.java:393)
        at co.elastic.apm.agent.premain.AgentMain.loadAndInitializeAgent(AgentMain.java:174)
        at co.elastic.apm.agent.premain.AgentMain.init(AgentMain.java:122)
        at co.elastic.apm.agent.premain.AgentMain.agentmain(AgentMain.java:67)
        at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:535)
2021-04-21 11:11:55,561 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Error trying to connect to APM Server. Some details about SSL configurations corresponding the current connection are logged at INFO level.
2021-04-21 11:11:55,561 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Failed to handle event of type JSON_WRITER with this error: Connection refused (Connection refused)
2021-04-21 11:11:55,561 [elastic-apm-server-reporter] INFO  co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Backing off for 36 seconds (+/-10%)
2021-04-21 11:11:55,709 [elastic-apm-configuration-reloader] WARN  co.elastic.apm.agent.shaded.stagemonitor.configuration.ConfigurationOption - Error in Attachment configuration: no protocol: 8200 Default value 'http://localhost:8200' for 'server_url' will be applied.
2021-04-21 11:11:56,176 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Error trying to connect to APM Server. Some details about SSL configurations corresponding the current connection are logged at INFO level.

Query:

It shows access denied exception ...How to fix this?

Note: For server_url i tried using properties file, --config server_url, --args server_url which usually works

elasticapm.properties:

service_name=sonar-service
server_url=https://elk:8200
log_file=/var/log/elastic-apm.log
0

There are 0 best solutions below