首页 > 解决方案 > 使用 AccessControlException 拒绝 Elastic APM 代理访问

问题描述

我正在为 sonarqube 实现 apm 代理,我可以使用 curl 连接到 apm 服务器

curl -v "" 返回 200

命令:

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

命令输出:

它显示代理已附加

日志文件:

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.

询问:

它显示访问被拒绝异常......如何解决这个问题?

注意: 对于 server_url,我尝试使用属性文件 --config server_url, --args server_url 这通常可以工作

elasticapm.properties:

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

标签: javasonarqubeelastic-stackelastic-apm

解决方案


推荐阅读