gpt4 book ai didi

java - 更新 NewRelic 版本在运行时抛出 AbstractMethodError

转载 作者:行者123 更新时间:2023-12-02 08:52:17 30 4
gpt4 key购买 nike

我正在项目中将 newrelic 版本从 2.x.x 更新到 5.x.x。我按照 newrelic 文档中提到的步骤进行操作(我更新了 pom 文件中的依赖项版本,更新了代理 jar 文件和配置文件)。

但是现在运行项目传递所需的 javaagent:

java -server -javaagent:/Users/amit.upadhyay/abcproject/abcproject-app/newrelic-stage/newrelic.jar -jar abcproject-app/target/abcproject-app-*.*.*-SNAPSHOT.jar /Users/amit.upadhyay/Downloads/abcproject.yml

我得到java.lang.AbstractMethodError。以下是错误日志:

ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://xml.org/sax/features/external-general-entities to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@e320068: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:205)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:420)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)   at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)  at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)   at com.newrelic.agent.logging.Log4jLogger.<init>(Log4jLogger.java:68)   at com.newrelic.agent.logging.Log4jLogger.create(Log4jLogger.java:415)  at com.newrelic.agent.logging.Log4jLogManager.createRootLogger(Log4jLogManager.java:38)     at com.newrelic.agent.logging.Log4jLogManager.initializeRootLogger(Log4jLogManager.java:98)     at com.newrelic.agent.logging.Log4jLogManager.<init>(Log4jLogManager.java:34)   at com.newrelic.agent.logging.Log4jLogManager.create(Log4jLogManager.java:254)  at com.newrelic.agent.logging.AgentLogManager.createAgentLogManager(AgentLogManager.java:19)    at com.newrelic.agent.logging.AgentLogManager.<clinit>(AgentLogManager.java:9)  at com.newrelic.agent.Agent.<clinit>(Agent.java:59)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179)    at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)  at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://xml.org/sax/features/external-parameter-entities to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@e320068: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V     at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:206)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:420)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)   at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)  at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)   at com.newrelic.agent.logging.Log4jLogger.<init>(Log4jLogger.java:68)   at com.newrelic.agent.logging.Log4jLogger.create(Log4jLogger.java:415)  at com.newrelic.agent.logging.Log4jLogManager.createRootLogger(Log4jLogManager.java:38)     at com.newrelic.agent.logging.Log4jLogManager.initializeRootLogger(Log4jLogManager.java:98)     at com.newrelic.agent.logging.Log4jLogManager.<init>(Log4jLogManager.java:34)   at com.newrelic.agent.logging.Log4jLogManager.create(Log4jLogManager.java:254)  at com.newrelic.agent.logging.AgentLogManager.createAgentLogManager(AgentLogManager.java:19)    at com.newrelic.agent.logging.AgentLogManager.<clinit>(AgentLogManager.java:9)  at com.newrelic.agent.Agent.<clinit>(Agent.java:59)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179)    at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)  at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://apache.org/xml/features/nonvalidating/load-external-dtd to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@e320068: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:207)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)   at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:420)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)    at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)  at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)   at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)  at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)   at com.newrelic.agent.logging.Log4jLogger.<init>(Log4jLogger.java:68)   at com.newrelic.agent.logging.Log4jLogger.create(Log4jLogger.java:415)  at com.newrelic.agent.logging.Log4jLogManager.createRootLogger(Log4jLogManager.java:38)     at com.newrelic.agent.logging.Log4jLogManager.initializeRootLogger(Log4jLogManager.java:98)     at com.newrelic.agent.logging.Log4jLogManager.<init>(Log4jLogManager.java:34)   at com.newrelic.agent.logging.Log4jLogManager.create(Log4jLogManager.java:254)  at com.newrelic.agent.logging.AgentLogManager.createAgentLogManager(AgentLogManager.java:19)    at com.newrelic.agent.logging.AgentLogManager.<clinit>(AgentLogManager.java:9)  at com.newrelic.agent.Agent.<clinit>(Agent.java:59)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179)    at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)  at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) Mar 16, 2020 01:40:38 +0530 [8698 1] com.newrelic INFO: Configuration file not found. The agent will attempt to read required values from environment variables. Mar 16, 2020 01:40:38 +0530 [8698 1] com.newrelic INFO: Using default collector host: collector.newrelic.com Mar 16, 2020 01:40:38 +0530 [8698 1] com.newrelic ERROR: Unable to start the New Relic Agent. Your application will continue to run but it will not be monitored. com.newrelic.agent.config.ConfigurationException: The agent requires an application name. Check the app_name setting in newrelic.yml    at com.newrelic.agent.config.ConfigServiceFactory.validateConfig(ConfigServiceFactory.java:64)  at com.newrelic.agent.config.ConfigServiceFactory.createConfigService(ConfigServiceFactory.java:27)

因为我在运行时遇到 AbstractMethodError ,即我在某处使用旧接口(interface),该接口(interface)在 newrelic java agent 5.x.x 新版本中更新。

错误日志表明我的项目中使用的 xerces 版本与更新的 newrelic javaagent 中的版本之间存在冲突。在谷歌搜索上我发现了这两个SO链接firstsecond有类似的问题。根据给出的答案,我添加了

        <dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>

到我的 pom 文件,这个 AbstractMethodError 错误消失了。

但是再次运行时我开始收到此异常:com.newrelic.agent.config.ConfigurationException

此异常的日志是:

Mar 16, 2020 02:37:18 +0530 [9598 1] com.newrelic INFO: Configuration file not found. The agent will attempt to read required values from environment variables.
Mar 16, 2020 02:37:18 +0530 [9598 1] com.newrelic INFO: Using default collector host: collector.newrelic.com
Mar 16, 2020 02:37:18 +0530 [9598 1] com.newrelic ERROR: Unable to start the New Relic Agent. Your application will continue to run but it will not be monitored.
com.newrelic.agent.config.ConfigurationException: The agent requires an application name. Check the app_name setting in newrelic.yml
at com.newrelic.agent.config.ConfigServiceFactory.validateConfig(ConfigServiceFactory.java:64) ~
at com.newrelic.agent.config.ConfigServiceFactory.createConfigService(ConfigServiceFactory.java:27) ~
at com.newrelic.agent.service.ServiceManagerImpl.<init>(ServiceManagerImpl.java:126) ~
at com.newrelic.agent.Agent.premain(Agent.java:279)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179)
at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386) [?:1.8.0_222]
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) [?:1.8.0_222]

现在,我不明白为什么会抛出 ConfigurationException (或者为什么它无法找到配置文件)。与旧版本的 newrelic 代理(2.x.x 或 3.x.x)一起使用时,相同的 java 命令(代理 jar 和配置文件的路径完全相同)可以完美运行。

我想了解这里出了什么问题/缺少什么?

最佳答案

我能够在我的项目中更新到最新的 newrelic 版本。他们似乎已经更新了 java 代理中的 xerces 版本,其中版本大于 5.0.0。除了更新 xerces 版本的修复之外,我还需要将 newrelic 配置文件显式作为系统属性传递,以解决 ConfigurationException

总体总结:- 将这些库更新为

        <dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>

并将 newrelic 配置文件作为系统属性传递:

-Dnewrelic.config.file=./${NEW_RELIC_DIR_NAME}/newrelic.yml

关于java - 更新 NewRelic 版本在运行时抛出 AbstractMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60698157/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com