access Mbeans on weblogic

后端 未结 1 1968
旧巷少年郎
旧巷少年郎 2021-01-07 01:19

From the documentation of oracle :

Domain Runtime MBean Server : This MBean server also acts as a single point of access for MBeans that reside on M

相关标签:
1条回答
  • 2021-01-07 01:52

    maybe my question wasnt clear but i found an answer and i will share it here now : Question summary : i need to access custom mBeans exists in a managed server by connecting to the administration server from a client application.

    Answer : to do that you need to deploy your application to the administrator server (i tried remote but it didn't work )

    you need to connect to the DomainRuntimeServiceMBean because it provide a common access point for navigating to all runtime and configuration MBeans in the domain .

    when searching for the Object name add Location=

    here is the code:

        Hashtable props = new Hashtable();
              props.put(Context.INITIAL_CONTEXT_FACTORY,
                        "weblogic.jndi.WLInitialContextFactory");
    
              props.put(Context.SECURITY_PRINCIPAL,   "<userName>");
              props.put(Context.SECURITY_CREDENTIALS, "<password>");
              Context ctx = new InitialContext(props);
      MBeanServer    server = (MBeanServer)ctx.lookup("java:comp/env/jmx/domainRuntime");
    
    
             ObjectName on =new ObjectName("com.<companyName>:Name=<Name>,Type=<Type>,Location=<managed_server_name>");
             boolean boolresult=(Boolean)server.invoke(on, "<method_Name>",
             new Object[]{"<ARG1>","<ARG2>","<ARG3>"}
             ,new String[]{"java.lang.String","java.lang.String","java.lang.String"}); 
             out.print(boolresult);
    
    0 讨论(0)
提交回复
热议问题