|
|
Spring Console Extension
Andy Piper's Blog |
July 6, 2006 2:11 AM
|
Comments (7)
The Spring on WebLogic Server paper described a new console extension that can be downloaded with the Spring on WebLogic kit. Many folks have had trouble getting this working, so I thought I would go over the setup once again and describe some of the gotchas.
Essentially the console extension displays registered spring beans in a table and allows you to call the accessors and mutators. In order to do this the beans needs to be exported via JMX and then registered with the console extension. The extension comes in two pieces, a client piece that gets packaged with your spring application and does the registration, and a server piece that gets packaged with the server and adds the extension page.
The first step in configuration is to add the relevant configuration to your spring applicationContext.xml. The config will look something like this:
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="petclinic:service=clinic" value-ref="clinic"/>
</map>
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="interfaceMappings">
<props>
<prop key="petclinic:service=clinic">org.springframework.samples.petclinic.jdbc.CachingClinic</prop>
</props>
</property>
</bean>
</property>
<property name="listeners">
<list>
<ref local="mediator"/>
</list>
</property>
<property name="autodetect" value="true"/>
<property name="server">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jmx/runtime"/>
</bean>
</property>
</bean>
<bean id="mediator" class="com.interface21.wl9.jmx.mediator.Mediator">
<property name="applicationName" value="petclinic"/>
</bean>
The first part of the config identifies which beans you will be exporting, so value-ref should refer to another bean in your config. However note that it is also crucial that the true application name be used for the ObjectName "petclinic:service=clinic" (i.e. the petclinic part). The console extension looks up beans based on special JMX ObjectNames built from the application name, and if these are not in sync you will see no beans.
The same applies to the interface mappings section further down. Note too that you must expose you beans via an interface, you cannot simply export a regular JavaBean. It is this interface that appears in the interfaceMappings section.
Finally the JMX exporter refers to a mediator that listens to events and publishes beans to the console as they are exported to JMX. The mediator section appears at the bottom, and again the applicationName must exactly match your application name, otherwise you will see no beans.
We plan to make the configuration of this much simpler very soon, so stay tuned. You can see the full set of properties for the MBeanExporter here.
Likewise you can see the configuration properties for the InterfaceBasedMBeanInfoAssembler here.
Once you have your config sorted, you need to build your application and include the console client extension. Unfortunately there was a bug in earlier builds of this and doubly unfortunately the builds of client and server pieces need to match. So I include both the server jar and client jar libraries here. I have verified these with WebLogic Server 9.1 and Spring 2.0-m5. They should work fine with earlier versions of Spring. The extension has been designed so that the version of Sping used by the server piece does not need to match that used by the client piece. You will however need to bundle the appropriate Spring jars with your application also.
Finnaly you need to configure the server extension, this simply involves dropping the server jar into the console-ext directory of your WebLogic Server configuration. Start the server run the app and you should be good to go. The extension appears as an extra tab called "Spring Management Objects" under the deployment entry for your application in the console.
Gotchas - there are a bunch of things that can go wrong here:
- If the tab does not appear then you likely have not configured the server extension correctly. The other possibility is that you are using autodeployment. autodeployment does not work with the console extension, you must use regular deployment.
- If you get the tab but no managed objects then most likely your application name does not match the one you configured. Also check that you are using the correct versions of the console extension, both server and client shown above.
- Clustering is not really supported at present - the beans are exported to the JMX server of the server on which they reside. The console must therefore also be running on this server. Its probably possible to use WebLogic Server's federated JMX server to look up beans remotely, but I have not tried that as yet.
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Do you know if this works on WebLogic 9.2?
Posted by: nuh@pfa.dk on July 13, 2006 at 12:36 AM
-
This doesn't work with 9.2 because the console extension API changed. Its not hard to resolve however, and we will be working on it.
Posted by: andypiper on July 13, 2006 at 12:42 AM
-
Is 8.1 supported ?
Posted by: sklimaye on August 6, 2006 at 1:34 PM
-
Is this now working on 9.2? Is there any different config?
Posted by: mirageman on January 24, 2008 at 10:11 AM
-
I am facing a problem while trying to monitor the Spring MBeans from the Admin Console using Spring Console Extensions. I deployed the spring application to Admin Server i am able to view the Spring MBeans on the console using Spring Management Objects Tab. But if I target the same application to Managed server and then try to view the Spring MBeans then i am not able to do so.
So you please let me know if this is Work As Designed or a bug or do I need to make any changes to the War file while targeting to managed server.
Does it mean that we cannot view the Spring MBeans using Admin Console if we target the application to Managed Server.
Any pointers will be highly appreciated.
Thanks in advance.
Regards,
Vishal Mahajan
Posted by: vmahajan on March 3, 2008 at 2:21 AM
-
Andy,
Why not state it very clearly in the WebLogic documentation that the ear packaging and clustered deployment are not supported (at least for v9.2), so people who might consider using this technology for real world applications won't end up wasting their time setting things up and figuring out why it doesn't work - only to eventually find out the reason through forums or sources like this blog?
Ivan
Posted by: igorgiev on March 18, 2008 at 9:58 AM
-
I opened a case (766878) at support, since a look at the code learned that only the local jndi was searched for.
An enhancement is prepared :
"As per our Product Management team, this issue is fixed in our Essex release (WLS 10.3) slated for this year. With Essex, you should be able to view and monitor the spring apps deployed to the managed server from your admin console. We removed the restriction that spring apps need to run on the admin server to be monitored and the tentative release date of Essex is June 16, 2008"
Luc
Posted by: axa on May 14, 2008 at 12:30 AM
|
|