This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch new-logging
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit e1548f7a2a5043f1cc1a171daec38f4418616b9e
Author: Clebert Suconic <[email protected]>
AuthorDate: Fri Jul 22 17:05:55 2022 -0400

    debugging stuff
    
    Robbie: This is a note for myself or for you in case you want to pick up 
from where I left.
    
    The issue is that ArtemisMBeanServerGuard::invoke is not being called for 
some reason.
    
    I tried to add System.outs here and there (although I should be using 
log.debug.. but I could not figure out the syntax now).
    
    I believe there's some initialization issue where SLF4j is not available 
when some JMX object is initialized. I have seen that happening a while ago 
with jboss-logging and it could be the case again. I believe this is why 
jboss-logging was added to the init classpath, although we could just not use 
log4j on classes that are loaded that early
    
    Anyway.. this is just a temporary commit that needs to be reverted once we 
figure out
---
 .../activemq/artemis/cli/commands/Configurable.java    |  8 +-------
 .../org/apache/activemq/artemis/cli/commands/Run.java  |  4 ++++
 .../artemis/cli/factory/jmx/ManagementFactory.java     |  7 +++++++
 .../server/management/ArtemisMBeanServerGuard.java     |  1 +
 .../core/server/management/ManagementContext.java      | 18 ++++++++++++------
 5 files changed, 25 insertions(+), 13 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
index 5767d57b75..23f9f4b4ce 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
@@ -34,16 +34,12 @@ import 
org.apache.activemq.artemis.core.config.impl.FileConfiguration;
 import org.apache.activemq.artemis.dto.BrokerDTO;
 import org.apache.activemq.artemis.dto.ManagementContextDTO;
 import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Abstract class where we can replace the configuration in various places *
  */
 public abstract class Configurable extends ActionAbstract {
 
-   private static final Logger logger = 
LoggerFactory.getLogger(Configurable.class);
-
    @Arguments(description = "Broker Configuration URI, default 
'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'")
    String configuration;
 
@@ -58,7 +54,6 @@ public abstract class Configurable extends ActionAbstract {
    private FileConfiguration fileConfiguration;
 
    protected void treatError(Exception e, String group, String command) {
-      logger.debug(e.getMessage(), e);
       System.err.println();
       System.err.println("Error:" + e.getMessage());
       System.err.println();
@@ -134,6 +129,7 @@ public abstract class Configurable extends ActionAbstract {
 
    protected ManagementContextDTO getManagementDTO() throws Exception {
       String configuration = getManagementConfiguration();
+      new Exception("Returning configuration " + 
configuration).printStackTrace();
       return ManagementFactory.createJmxAclConfiguration(configuration, 
getBrokerHome(), getBrokerInstance(), getBrokerURIInstance());
    }
 
@@ -144,8 +140,6 @@ public abstract class Configurable extends ActionAbstract {
 
          // To support Windows paths as explained above.
          configuration = configuration.replace("\\", "/");
-
-         logger.debug("Using broker configuration: {}", configuration);
       }
 
       return configuration;
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
index a12c7aa707..373ab9ea2a 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
@@ -82,6 +82,8 @@ public class Run extends LockAbstract {
          ManagementContextDTO managementDTO = getManagementDTO();
          managementContext = ManagementFactory.create(managementDTO, 
securityManager);
 
+         System.out.println("Management context::" + managementContext);
+
          Artemis.printBanner();
 
          addShutdownHook(broker.server.getConfigurationFile().getParentFile());
@@ -91,7 +93,9 @@ public class Run extends LockAbstract {
             public void preActivate() {
                try {
                   managementContext.start();
+                  System.out.println("Management context started");
                } catch (Exception e) {
+                  e.printStackTrace();
                   ActiveMQServerLogger.LOGGER.unableStartManagementContext(e);
                   return;
                }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
index 1a409f325d..b0e267ed1d 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
@@ -32,12 +32,15 @@ import 
org.apache.activemq.artemis.core.server.management.JMXAccessControlList;
 import org.apache.activemq.artemis.dto.WhiteListDTO;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 import org.apache.activemq.artemis.utils.FactoryFinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.net.URI;
 import java.util.List;
 
 public class ManagementFactory {
+   private static Logger log = 
LoggerFactory.getLogger(ManagementFactory.class);
 
    private static ManagementContextDTO createJmxAclConfiguration(URI configURI,
                                                                  String 
artemisHome,
@@ -81,10 +84,13 @@ public class ManagementFactory {
 
          AllowListDTO allowList = authorisation.getAllowList();
          if (allowList != null) {
+            log.debug("Allow list {}", allowList);
+            new Exception("allowList" + allowList).printStackTrace();
             if (whiteList != null) {
                ActiveMQServerLogger.LOGGER.useOnlyAllowList();
             }
             for (EntryDTO entry : allowList.getEntries()) {
+               System.out.println("Adding entry::" + entry.domain + " " + 
entry.key);
                accessControlList.addToAllowList(entry.domain, entry.key);
             }
          }
@@ -103,6 +109,7 @@ public class ManagementFactory {
                accessControlList.addToRoleAccess(match.getDomain(), 
match.getKey(), access.method, split);
             }
          }
+         System.out.println("Access control list " + accessControlList);
          context.setAccessControlList(accessControlList);
       }
 
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java
index 8b51c2ab26..d604c07c35 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java
@@ -50,6 +50,7 @@ public class ArtemisMBeanServerGuard implements 
InvocationHandler {
 
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws 
Throwable {
+      new Exception("Invoking ").printStackTrace();
       if (method.getParameterTypes().length == 0)
          return null;
 
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementContext.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementContext.java
index db308acdfc..a80e97050f 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementContext.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementContext.java
@@ -35,12 +35,17 @@ public class ManagementContext implements ServiceComponent {
    private ActiveMQSecurityManager securityManager;
 
    public void init() {
-      if (accessControlList != null) {
-         //if we are configured then assume we want to use the guard so set 
the system property
-         System.setProperty("javax.management.builder.initial", 
ArtemisMBeanServerBuilder.class.getCanonicalName());
-         guardHandler = new ArtemisMBeanServerGuard();
-         guardHandler.setJMXAccessControlList(accessControlList);
-         ArtemisMBeanServerBuilder.setGuard(guardHandler);
+      try {
+         new Exception("Access Control List = " + 
accessControlList).printStackTrace();
+         if (accessControlList != null) {
+            //if we are configured then assume we want to use the guard so set 
the system property
+            System.setProperty("javax.management.builder.initial", 
ArtemisMBeanServerBuilder.class.getCanonicalName());
+            guardHandler = new ArtemisMBeanServerGuard();
+            guardHandler.setJMXAccessControlList(accessControlList);
+            ArtemisMBeanServerBuilder.setGuard(guardHandler);
+         }
+      } catch (Throwable e) {
+         e.printStackTrace();
       }
    }
 
@@ -115,6 +120,7 @@ public class ManagementContext implements ServiceComponent {
    }
 
    public ArtemisMBeanServerGuard getArtemisMBeanServerGuard() {
+      new Exception("Returning guardHandler").printStackTrace();
       return guardHandler;
    }
 

Reply via email to