Skip to main content

Taming the JMX on WebLogic Server

Taming the JMX on WebLogic Server


Taming the JMX on WebLogic Server

Let assume couple things first:

1) I assume you have heard of Java’s JMX features and familiar what it does (expose and manage your service remotely). You ought to know that default JVM will have a Platform MBeanServer instance that you can register MBean. And you may view them using the jconsole command from the JDK.

2) As of today, I think by far the easiest way you can expose any services in your application to a JMX MBeanServer is using Spring’s exporter. You will do something like this:

 <bean class="org.springframework.jmx.export.MBeanExporter">
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="managedInterfaces">
<list>
<!-- Expose any java interface you like to see under JMX as MBean -->
<value>myproject.services.Service</value>
</list>
</property>
</bean>
</property>
<property name="beans">
<map>
<entry key="myproject.services:name=MyCoolService" value-ref="myCoolService"/>
</map>
</property>
</bean>
<!-- This service must implements the interface used above -->
<bean id="myCoolService" class="myproject.services.MyCoolService">
</bean>

Above should get you standalone application with JMX enabled.

Now if you want to do similar on WebLogic Server, then I have few goodies and notes that might help you. Read on…

WebLogic Server’s (WLS) MBeanServer

The JConsole trick

The WLS, like many other EE server will have it’s own MBeanServer. However, to see the MBean’s you would need to do little extra with jconsole. Assume you have a default config WLS started on localhost, then you can connect to it like this.

jconsole -J-Djava.class.path="$JAVA_HOME/lib/jconsole.jar:$MW_HOME/wlserver/server/lib/wljmxclient.jar" -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote

Then when prompted to login, enter the following:

Remote Process: service:jmx:iiop://localhost:7001/jndi/weblogic.management.mbeanservers.runtime
User: <same userid you used setup WLS to their console app.>
Password: <same password you used setup WLS to their console app.>

Now you should see all the MBeans that WLS already exposed to you as a EE server. You may add your own service there.

Programming with JMX connection

You may connect to the WLS MBeanServer remotely inside your standalone application. Here is a typical connection code you would need

 String serviceName = "com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean";
try {
ObjectName service = new ObjectName(serviceName);
} catch (MalformedObjectNameException e) {
throw new RuntimeException("Not able to create JMX ObjectName: " + serviceName);
}

String protocol = "t3";
String jndiroot = "/jndi/";
String mserver = "weblogic.management.mbeanservers.runtime";
try {
JMXServiceURL serviceURL = new JMXServiceURL(protocol, "localhost", 7001, jndiroot + mserver);

Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, username);
h.put(Context.SECURITY_CREDENTIALS, password);
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
"weblogic.management.remote");
h.put("jmx.remote.x.request.waiting.timeout", new Long(10000));
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
MBeanServerConnection remoteMBeanServer = connector.getMBeanServerConnection();

// TODO: Do what you need with remoteMBeanServer here.
} catch (Exception e) {
throw new RuntimeException("Not able to initiate MBeanServer protocol= " + protocol +
", jndiroot= " + jndiroot + ", mserver= " + mserver);
}

That’s a mouthful of boiler code just to get a remote MBeanServer connection! Fortunately there is another easier way though. Read on…

The JNDI trick

The WLS MBeanServer service is also available through JNDI lookup. Again Spring can help you with their JNDI lookup and you simply need to inject it to other services that need it. For example:

 <bean id="jmxServerRuntime" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jmx/runtime"/>
</bean>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="myproject.services:name=MyCoolService" value-ref="myCoolService"/>
</map>
</property>
<property name="server" ref="jmxServerRuntime"/>
</bean>

Notice that we have injetcted the "server" property with one we looked up from WLS JNDI service. If you use that in your WAR application and deploy it onto a WLS instance, and whola, you got yourself exposed service onto WLS JMX!

Note
above will only works if your Spring xml config is part of the WAR/JAR/EAR that’s deployed in same server where JNDI lives! If you are not, you need to use this JNDI name without the "env" part instead, like "java:comp/env/jmx/runtime".

For more details on how to work with JMX and WLS, see their docs here: http://docs.oracle.com/cd/E12839_01/web.1111/e13728/accesswls.htm#i1119556


download file now

Popular posts from this blog

Talking Tom Cat for Symbian 3 Nokia N8 E6 E7 C7 C6 01 X7 and more Full Version App Download

Talking Tom Cat for Symbian 3 Nokia N8 E6 E7 C7 C6 01 X7 and more Full Version App Download Talking Tom Cat is really a superb Application. In this app you can pet him, you can even grab his tail, poke him and even you can talk with him. Tom will repeat anything in his voice you will say to him. Enjoy your free time with with Talking Tom Cat. This is really a fun especially fun for children of all ages. How to Play with Talking Tom Cat: You can talk to him and he will repeat in his voice what ever you have said Pet his body or head to make him purr. Poke his head, belly or feet. Grab his tail. Pour a glass of milk for him to drink. Forget about him and he will yawn or sneeze.   Click Link Below to Download: Talking Tom Cat for Symbian ^ 3 (Nokia N8, E6 , E7, C7, C6-01, X7 and more) - Full Version App Download Talking Tom Cat for Symbian ^ 3 (Nokia N8, E6 , E7, C7, C6-01, X7 and more) - Full Version App Download download  file  now

Tokyo Ghoul Season 1 BD Subtitle Indonesia

Tokyo Ghoul Season 1 BD Subtitle Indonesia Tokyo Ghoul Season 1 BD Subtitle Indonesia Type: BD Series Episode: 12 Status: Completed Genres: Action, Mystery, Drama, Horror, Supernatural, Psychological, Seinen Skor : 8.10 (http://myanimelist.net/anime/22319/Tokyo_Ghoul) Tahun Rilis : 2014 Subtitle : Indonesia Credit : http://anime-bd.com/ Deskripsi: Ketegangan horor yang berada di kota Tokyo dihantui oleh hantu misterius yang memakan manusia. Orang-orang dicekam rasa takut hantu ini yang identitasnya disembunyikan. Seorang mahasiswa biasa bernama Kaneki bertemu ceweknya yang bernama Rize, seorang gadis yang merupakan pembaca  novel seperti dia, di kafe dia sering berjumpa denganya. Perlahan dia kemudian menyadari bahwa nasibnya akan berubah dalam semalam setelah bertemu Rize. Link download 720p & 480p: ===================================================== ========= Resolusi 720p: Tusfiles: Ani-BD_Tokyo_Ghoul_BD_ED01_animesave.mkv � 11.5 MB Ani-BD_Tokyo_Ghoul_BD_ED02_animesave.m...

Tarzan

Tarzan Tarzan Action Game (PC/Full/Eng) Game Platforme(s) : PC | Language : English | Release Date : Feb 16, 1999 Publisher & Developer : Disney Interactive | Genre : Action/Adventure | Size : 38 Mb Tarzan Action GameSummer. The days are hot and long, and its time for bar-b-ques, camping, and baseball. Summer doesnt just happen outside, though. Its also blockbuster movie season, when theaters screen entertainment thats typically a little lighter in content and more technically dazzling than the award-oriented films shown in the colder, darker, shorter days of fall and winter. Accordingly, summer big-screen fun has come to belong to Disney, which releases an animated feature every year to coincide with the conditions that make it easy to spend an afternoon in an air conditioned movie house, often time and time again to see the same feature over and over. If youve spent any time near fast-food franchises or a department store, then you know from all the merchandise that this years ...