Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when url in Log4j2Plugin is null #201

Closed
mpeterka opened this issue Jun 1, 2017 · 1 comment
Closed

NullPointerException when url in Log4j2Plugin is null #201

mpeterka opened this issue Jun 1, 2017 · 1 comment

Comments

@mpeterka
Copy link

mpeterka commented Jun 1, 2017

HOTSWAP AGENT: 09:56:08.424 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.log4j2.Log4j2Plugin' initialized in ClassLoader 'ContextLoader@Service Provisioning Manager - Service Provisioning'.
HOTSWAP AGENT: 09:56:08.430 ERROR (org.hotswap.agent.plugin.log4j2.Log4j2Plugin) - Exception initializing Log4j2 on uri null.
java.lang.NullPointerException
	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:98)
	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
	at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
	at java.nio.file.Paths.get(Paths.java:84)
	at org.hotswap.agent.plugin.log4j2.Log4j2Plugin.init(Log4j2Plugin.java:62)
	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 org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:551)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:551)
	at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:49)
	at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)
	at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:72)
	at org.elasticsearch.common.component.AbstractComponent.<init>(AbstractComponent.java:37)
	at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:98)
	at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:94)
	at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:119)
	at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:247)
	at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:92)
	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:55)
	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:50)
	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:46)	

Suggested patch:

Index: plugin/hotswap-agent-log4j2-plugin/src/main/java/org/hotswap/agent/plugin/log4j2/Log4j2Plugin.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- plugin/hotswap-agent-log4j2-plugin/src/main/java/org/hotswap/agent/plugin/log4j2/Log4j2Plugin.java	(revision 4b7498df239e24f0fdbd2c0be2e795c6f6b0d670)
+++ plugin/hotswap-agent-log4j2-plugin/src/main/java/org/hotswap/agent/plugin/log4j2/Log4j2Plugin.java	(revision 06b8d95deaf6d2a3deacd9f05f4096f341c4084f)
@@ -59,6 +59,9 @@
 
             Object configurationSource = configurationClass.getDeclaredMethod("getConfigurationSource").invoke(config);
             String url = (String) configurationSourceClass.getDeclaredMethod("getLocation").invoke(configurationSource);
+            if (url == null) {
+                LOGGER.warning("Location url is NULL on configurationSource={} - exiting.", configurationSource);
+            }
             configURI = Paths.get(url).toUri();
 
             if (registeredURIs.contains(configURI)) {

@himanshumehta47
Copy link

Is it fixed yet? if yes can you please let me know which version of hotswap-agent.jar to use?

@skybber skybber closed this as completed in 7fce1c8 Jan 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants