Question

I have searched the Weblogic documentation extensively:

All the documentation on the Oracle site and all the examples I have found so far only show how to get a reference to this MBean via a Remote connection or to an instance of MBeanServer locally.

The little bit that mentions a local connection is vague and incomplete:

Absolute JNDI name of the MBean server. The JNDI name must start with /jndi/ and be followed by one of the JNDI names described in Table 4-1.

Table 4-1 shows:

MBean Server                  JNDI Name
Domain Runtime MBean Server   weblogic.management.mbeanservers.domainruntime

This doesn't work, I tried dumping the JNDI tree and can't find anything relevant in there.

I am on the AdminServer so that isn't the issue.

What I can find instructions to do that works is getting a reference to an instance of MBServer, but that isn't what I need; example: (MBeanServer) ctx.lookup("java:comp/env/jmx/domainRuntime");

But this doesn't do me any good, it is an instance of MBeanServer and I don't want to dig through all the indirection with the ObjectName stuff.

What I need to reference is DomainRuntimeServiceMBean interface:

What I need is to be able to get an instance of DomainRuntimeServiceMBean - JavaDoc

Was it helpful?

Solution

Short Answer

The type safe interfaces are all Deprecated, you have to do the lookup/tree walking manually.

As of 9.0, the MBeanHome interface and all type-safe interfaces for WebLogic Server MBeans are deprecated. Instead, JMX applications that interact with WebLogic Server MBeans should use standard JMX design patterns in which clients use the javax.management.MBeanServerConnection interface to discover MBeans, attributes, and attribute types at runtime.

Long Answer

private InitialContext ctx;
private MBeanServer domain;
private ObjectName domainObjectName;

In the constructor:

ctx = new InitialContext();
this.domain = (MBeanServer) ctx.lookup("java:comp/env/jmx/domainRuntime");
this.domainObjectName = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");

In your method:

final ObjectName dr = (ObjectName) this.domain.getAttribute(domainObjectName, "DomainRuntime");
final ObjectName dm = (ObjectName) this.domain.getAttribute(dr, "DeploymentManager");
final ObjectName[] adrs = (ObjectName[]) this.domain.getAttribute(dm, "AppDeploymentRuntimes");
for (final ObjectName on : adrs)
{
    if (this.domain.getAttribute(on, "ApplicationName").equals(appName))
    {
        this.domain.invoke(on, "stop", null, null);
        break;
    }
}

Of course now I have to write my own convenience classes that are typesafe to wrap all this verbose non-sense!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top