【问题标题】:Updating NewRelic version throwing AbstractMethodError at runtime更新 NewRelic 版本在运行时抛出 AbstractMethodError
【发布时间】:2023-03-07 13:46:01
【问题描述】:

我正在一个项目中将 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,即在某处我正在使用旧接口,该接口在新版本的 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 和配置文件的路径完全相同)运行完美。

我想了解这里出了什么问题/遗漏了什么?

【问题讨论】:

    标签: java maven newrelic xerces


    【解决方案1】:

    我能够在我的项目中更新到最新的 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
    

    【讨论】:

      猜你喜欢
      • 2016-02-16
      • 2019-03-02
      • 2010-12-30
      • 2020-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-31
      • 2021-11-12
      相关资源
      最近更新 更多