[ 
https://issues.apache.org/jira/browse/GEODE-8197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17127122#comment-17127122
 ] 

ASF GitHub Bot commented on GEODE-8197:
---------------------------------------

kirklund commented on a change in pull request #5196:
URL: https://github.com/apache/geode/pull/5196#discussion_r436186564



##########
File path: 
geode-assembly/src/acceptanceTest/java/org/apache/geode/launchers/LocatorLauncherWithPulseAndCustomLogConfigAcceptanceTest.java
##########
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.launchers;
+
+import static java.nio.file.Files.copy;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+import static org.apache.geode.test.util.ResourceUtils.createFileFromResource;
+import static org.apache.geode.test.util.ResourceUtils.getResource;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.test.assertj.LogFileAssert;
+import org.apache.geode.test.junit.rules.RequiresGeodeHome;
+
+public class LocatorLauncherWithPulseAndCustomLogConfigAcceptanceTest {
+
+  private static final String CONFIG_WITH_GEODE_PLUGINS_FILE_NAME =
+      
"LocatorLauncherWithPulseAndCustomLogConfigAcceptanceTestWithGeodePlugins.xml";
+  private static final String CONFIG_WITHOUT_GEODE_PLUGINS_FILE_NAME =
+      
"LocatorLauncherWithPulseAndCustomLogConfigAcceptanceTestWithoutGeodePlugins.xml";
+  private static final String LOCATOR_NAME = "the-locator";
+
+  private int locatorPort;
+  private int httpServicePort;
+  private Path configWithGeodePluginsFile;
+  private Path configWithoutGeodePluginsFile;
+  private Process locator;
+  private Path geodeDependencies;
+  private Path stdoutFile;
+  private Path locatorLogFile;
+  private Path pulseLogFile;
+
+  @Rule
+  public RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome();
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public void setUpLogConfigFiles() {
+    configWithGeodePluginsFile = createFileFromResource(
+        getResource(CONFIG_WITH_GEODE_PLUGINS_FILE_NAME), 
temporaryFolder.getRoot(),
+        CONFIG_WITH_GEODE_PLUGINS_FILE_NAME)
+            .toPath();
+
+    configWithoutGeodePluginsFile = createFileFromResource(
+        getResource(CONFIG_WITHOUT_GEODE_PLUGINS_FILE_NAME), 
temporaryFolder.getRoot(),
+        CONFIG_WITHOUT_GEODE_PLUGINS_FILE_NAME)
+            .toPath();
+  }
+
+  @Before
+  public void setUpGeodeDependencies() {
+    Path geodeHome = requiresGeodeHome.getGeodeHome().toPath();
+    geodeDependencies = geodeHome.resolve("lib/geode-dependencies.jar");
+
+    assertThat(geodeDependencies).exists();
+  }
+
+  @Before
+  public void setUpOutputFiles() {
+    stdoutFile = temporaryFolder.getRoot().toPath().resolve("stdout.txt");
+    locatorLogFile = temporaryFolder.getRoot().toPath().resolve(LOCATOR_NAME + 
".log");
+    pulseLogFile = temporaryFolder.getRoot().toPath().resolve("pulse.log");
+  }
+
+  @Before
+  public void setUpRandomPorts() {
+    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    locatorPort = ports[0];
+    httpServicePort = ports[1];
+  }
+
+  @After
+  public void stopLocator() throws Exception {
+    if (locator != null) {
+      locator.destroyForcibly().waitFor(4, TimeUnit.SECONDS);
+    }
+  }
+
+  @Test
+  public void locatorLauncherUsesSpecifiedConfigFileWithoutGeodePlugins() 
throws Exception {
+    ProcessBuilder processBuilder = new ProcessBuilder()
+        .redirectErrorStream(true)
+        .redirectOutput(stdoutFile.toFile())
+        .directory(temporaryFolder.getRoot())
+        .command("java",
+            "-Dgemfire.http-service-port=" + httpServicePort,
+            "-Dgemfire.jmx-manager-start=true",
+            "-Djava.awt.headless=true",
+            "-Dlog4j.configurationFile=" + 
configWithoutGeodePluginsFile.toAbsolutePath(),
+            "-cp", geodeDependencies.toFile().getAbsolutePath(),
+            "org.apache.geode.distributed.LocatorLauncher", "start", 
LOCATOR_NAME,
+            "--port", String.valueOf(locatorPort));
+
+    System.out.println("Launching command: " + processBuilder.command());
+
+    locator = processBuilder
+        .start();
+
+    assertThat(locator.isAlive()).isTrue();
+
+    await().untilAsserted(() -> {
+      assertThat(locatorLogFile)
+          .doesNotExist();
+
+      assertThat(pulseLogFile)
+          .doesNotExist();
+
+      LogFileAssert.assertThat(stdoutFile.toFile())
+          .exists()
+          .contains("Located war: geode-pulse")
+          .contains("Adding webapp /pulse")
+          .contains("Starting server location for Distribution Locator")
+          .doesNotContain("geode-pulse war file was not found")
+          .doesNotContain("java.lang.IllegalStateException: No factory method 
found for class");
+    });
+  }
+
+  @Test
+  public void locatorLauncherUsesConfigFileInClasspathWithoutGeodePlugins() 
throws Exception {
+    copy(configWithoutGeodePluginsFile, 
temporaryFolder.getRoot().toPath().resolve("log4j2.xml"));
+
+    String classpath = temporaryFolder.getRoot().getAbsolutePath() + 
File.pathSeparator +
+        geodeDependencies.toFile().getAbsolutePath();
+
+    ProcessBuilder processBuilder = new ProcessBuilder()
+        .redirectErrorStream(true)
+        .redirectOutput(stdoutFile.toFile())
+        .directory(temporaryFolder.getRoot())
+        .command("java",
+            "-Dgemfire.http-service-port=" + httpServicePort,
+            "-Dgemfire.jmx-manager-start=true",
+            "-Djava.awt.headless=true",
+            "-cp", classpath,
+            "org.apache.geode.distributed.LocatorLauncher", "start", 
LOCATOR_NAME,
+            "--port", String.valueOf(locatorPort));
+
+    System.out.println("Launching command: " + processBuilder.command());
+
+    locator = processBuilder
+        .start();
+
+    assertThat(locator.isAlive()).isTrue();
+
+    await().untilAsserted(() -> {
+      assertThat(locatorLogFile)
+          .doesNotExist();
+
+      assertThat(pulseLogFile)
+          .doesNotExist();
+
+      LogFileAssert.assertThat(stdoutFile.toFile())
+          .exists()
+          .contains("Located war: geode-pulse")
+          .contains("Adding webapp /pulse")
+          .contains("Starting server location for Distribution Locator")
+          .doesNotContain("geode-pulse war file was not found")
+          .doesNotContain("java.lang.IllegalStateException: No factory method 
found for class");
+    });
+  }
+
+  @Test
+  @Ignore("GEODE-8197")
+  public void locatorLauncherUsesSpecifiedConfigFileWithGeodePlugins() throws 
Exception {
+    ProcessBuilder processBuilder = new ProcessBuilder()
+        .redirectErrorStream(true)
+        .redirectOutput(stdoutFile.toFile())
+        .directory(temporaryFolder.getRoot())
+        .command("java",
+            "-Dgemfire.http-service-port=" + httpServicePort,
+            "-Dgemfire.jmx-manager-start=true",
+            "-Djava.awt.headless=true",
+            "-Dlog4j.configurationFile=" + 
configWithGeodePluginsFile.toAbsolutePath(),
+            "-cp", geodeDependencies.toFile().getAbsolutePath(),
+            "org.apache.geode.distributed.LocatorLauncher", "start", 
LOCATOR_NAME,
+            "--port", String.valueOf(locatorPort));
+
+    System.out.println("Launching command: " + processBuilder.command());
+
+    locator = processBuilder
+        .start();
+
+    assertThat(locator.isAlive()).isTrue();
+
+    await().untilAsserted(() -> {
+      assertThat(locatorLogFile)
+          .doesNotExist();
+
+      assertThat(pulseLogFile)
+          .doesNotExist();
+
+      LogFileAssert.assertThat(stdoutFile.toFile())
+          .exists()
+          .contains("Located war: geode-pulse")
+          .contains("Adding webapp /pulse")
+          .contains("Starting server location for Distribution Locator")
+          .doesNotContain("geode-pulse war file was not found")
+          .doesNotContain("java.lang.IllegalStateException: No factory method 
found for class");
+    });
+  }
+
+  @Test
+  @Ignore("GEODE-8197")

Review comment:
       Yes. This PR is only creating new tests. I'll follow up in the future 
with a fix.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Embedded Pulse fails to start with custom log4j2.xml
> ----------------------------------------------------
>
>                 Key: GEODE-8197
>                 URL: https://issues.apache.org/jira/browse/GEODE-8197
>             Project: Geode
>          Issue Type: Bug
>          Components: logging, pulse
>            Reporter: Kirk Lund
>            Assignee: Kirk Lund
>            Priority: Major
>              Labels: GeodeOperationAPI
>
> Starting a Locator with a custom log4j2.xml referencing Geode appenders or 
> converters fails to correctly start embedded Pulse web application.
> {noformat}
> [info 2020/05/28 10:51:51.954 PDT <main> tid=1] Adding webapp /pulse
> 2020-05-28 10:51:53,328 main ERROR Unable to invoke factory method in class 
> org.apache.geode.alerting.log4j.internal.impl.AlertAppender for element 
> GeodeAlert: java.lang.IllegalStateException: No factory method found for 
> class org.apache.geode.alerting.log4j.internal.impl.AlertAppender 
> java.lang.IllegalStateException: No factory method found for class 
> org.apache.geode.alerting.log4j.internal.impl.AlertAppender
>       at 
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:234)
>       at 
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:134)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
>       at 
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:618)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:691)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:708)
>       at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
>       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.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:138)
>       at 
> org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
>       at 
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:48)
>       at 
> org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
>       at 
> org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
>       at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
>       at 
> org.springframework.web.filter.GenericFilterBean.<init>(GenericFilterBean.java:86)
>       at 
> org.springframework.web.filter.DelegatingFilterProxy.<init>(DelegatingFilterProxy.java:107)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>       at 
> org.eclipse.jetty.server.handler.ContextHandler$Context.createInstance(ContextHandler.java:2520)
>       at 
> org.eclipse.jetty.servlet.ServletContextHandler$Context.createFilter(ServletContextHandler.java:1284)
>       at 
> org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:118)
>       at 
> org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:751)
>       at 
> java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
>       at 
> java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)
>       at 
> java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)
>       at 
> java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
>       at 
> org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744)
>       at 
> org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:361)
>       at 
> org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1443)
>       at 
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1407)
>       at 
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:821)
>       at 
> org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:276)
>       at 
> org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
>       at 
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
>       at 
> org.apache.geode.internal.cache.InternalHttpService.addWebApplication(InternalHttpService.java:211)
>       at 
> org.apache.geode.management.internal.ManagementAgent.loadWebApplications(ManagementAgent.java:248)
>       at 
> org.apache.geode.management.internal.ManagementAgent.startAgent(ManagementAgent.java:133)
>       at 
> org.apache.geode.management.internal.SystemManagementService.startManager(SystemManagementService.java:375)
>       at 
> org.apache.geode.distributed.internal.InternalLocator.lambda$startClusterManagementService$3(InternalLocator.java:826)
>       at java.util.Optional.ifPresent(Optional.java:159)
>       at 
> org.apache.geode.distributed.internal.InternalLocator.startClusterManagementService(InternalLocator.java:817)
>       at 
> org.apache.geode.distributed.internal.InternalLocator.startClusterManagementService(InternalLocator.java:783)
>       at 
> org.apache.geode.distributed.internal.InternalLocator.startCache(InternalLocator.java:776)
>       at 
> org.apache.geode.distributed.internal.InternalLocator.startDistributedSystem(InternalLocator.java:757)
>       at 
> org.apache.geode.distributed.internal.InternalLocator.startLocator(InternalLocator.java:388)
>       at 
> org.apache.geode.distributed.LocatorLauncher.start(LocatorLauncher.java:716)
>       at 
> org.apache.geode.distributed.LocatorLauncher.run(LocatorLauncher.java:623)
>       at 
> org.apache.geode.distributed.LocatorLauncher.main(LocatorLauncher.java:217)
> 2020-05-28 10:51:53,331 main ERROR appenders Appenders has no parameter that 
> matches element GeodeAlert
> 2020-05-28 10:51:53,344 main ERROR Unable to locate appender "ALERT" for 
> logger config "root"
> [info 2020/05/28 10:51:53.404 PDT <main> tid=1] Initializing Servlet 'pulse'
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to