You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/07/25 19:47:20 UTC

[activemq-artemis] branch new-logging updated (7299b43f05 -> b9bef72a17)

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

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


 discard 7299b43f05 Verifying JMX Security and setting up javax.management.builder.initial before Log4J starts its own JMX
     new b9bef72a17 Verifying JMX Security and setting up javax.management.builder.initial before Log4J starts its own JMX

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (7299b43f05)
            \
             N -- N -- N   refs/heads/new-logging (b9bef72a17)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java | 3 +++
 1 file changed, 3 insertions(+)


[activemq-artemis] 01/01: Verifying JMX Security and setting up javax.management.builder.initial before Log4J starts its own JMX

Posted by cl...@apache.org.
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 b9bef72a17fed19c44e5a45685186e97a5d19943
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Mon Jul 25 15:30:50 2022 -0400

    Verifying JMX Security and setting up javax.management.builder.initial before Log4J starts its own JMX
    
    The other option would be to disable log4j's JMX which should actually make sense
---
 .../org/apache/activemq/artemis/cli/Artemis.java   | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index 91cbeead5d..c131b6fbb1 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -71,6 +71,8 @@ import org.apache.activemq.artemis.cli.commands.user.HelpUser;
 import org.apache.activemq.artemis.cli.commands.user.ListUser;
 import org.apache.activemq.artemis.cli.commands.user.RemoveUser;
 import org.apache.activemq.artemis.cli.commands.user.ResetUser;
+import org.apache.activemq.artemis.dto.ManagementContextDTO;
+import org.apache.activemq.artemis.dto.XmlUtil;
 
 /**
  * Artemis is the main CLI entry point for managing/running a broker.
@@ -79,6 +81,9 @@ import org.apache.activemq.artemis.cli.commands.user.ResetUser;
  * run.  Make sure set the -Dartemis.instance=path/to/instance system property.
  * You should also use the 'apache-artemis' module for the class path since that
  * includes all artemis modules.
+ *
+ * Notice that this class should not use any logging as it's part of the bootstrap and using logging here could
+ *        disrupt the order of bootstrapping on certain components (e.g. JMX being started from log4j)
  */
 public class Artemis {
 
@@ -88,9 +93,31 @@ public class Artemis {
       String instance = System.getProperty("artemis.instance");
       File fileInstance = instance != null ? new File(instance) : null;
 
+      verifyManagementDTO(fileInstance);
+
       execute(true, fileHome, fileInstance, args);
    }
 
+
+   // Notice this has to happen before any Log4j is used.
+   //        otherwise Log4j's JMX will start the JMX before this property was able to tbe set
+   public static void verifyManagementDTO(File fileInstance) {
+      if (fileInstance != null) {
+
+         File etc = new File(fileInstance, "etc");
+         File management = new File(etc, "management.xml");
+
+         try {
+            ManagementContextDTO managementContextDTO = XmlUtil.decode(ManagementContextDTO.class, management);
+            if (managementContextDTO != null && managementContextDTO.getAuthorisation() != null) {
+               System.setProperty("javax.management.builder.initial", "org.apache.activemq.artemis.core.server.management.ArtemisMBeanServerBuilder");
+            }
+         } catch (Exception e) {
+            e.printStackTrace();
+         }
+      }
+   }
+
    public static Object internalExecute(String... args) throws Exception {
       return internalExecute(null, null, args);
    }
@@ -101,6 +128,8 @@ public class Artemis {
 
    public static Object execute(boolean inputEnabled, File artemisHome, File artemisInstance, ActionContext context, String... args) throws Exception {
 
+      verifyManagementDTO(artemisInstance);
+
       if (inputEnabled) {
          InputAbstract.enableInput();
       }