Announcement Announcement Module
Collapse
No announcement yet.
<context:mbean-export/> on Weblogic Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <context:mbean-export/> on Weblogic

    It seems to me as if the following short hand:

    <context:mbean-export/>

    coupled with the annotations as such:

    Code:
    @ManagedResource(objectName="caching:name=cacheManagerJMX", description="Cache Management Bean")
    public class CacheManagerMBeanImpl implements CacheManagerJMXIntf {
    	@Resource
    	CacheManagerMBeanIntf cacheManager;
    	
    	@PostConstruct
    	public void init()
    	{
    		System.out.println("CacheManagerMBeanImpl fired up with cacheManager = " + cacheManager);
    	}
    	
    	@Override
    	@ManagedOperation(description="Flush all caches")
    	public void flushAllCaches() {
    		Collection<CacheMBeanIntf> caches = cacheManager.getAllCaches();
    		for (CacheMBeanIntf cache : caches) {
    			cache.flush();
    		}
    	}
    }
    Does not work properly on Weblogic 10.3. I have installed all the Spring Framework extensions and the MBeans show up, but when I fire up JConsole they do not appear.

    If I export my MBeans using the following:

    Code:
    <bean id="exporter"
    		class="org.springframework.jmx.export.MBeanExporter"
    		lazy-init="false">
    		<property name="beans">
    			<map>
    				<entry key="caching:name=cacheManager"
    					value-ref="cacheMBean" />
    			</map>
    		</property>
    	</bean>
    It works just fine.

    Thoughts?
    Last edited by difranr; Nov 16th, 2009, 02:02 PM.

  • #2
    Hmm in theory it should work. Both the mbean-export and the concerning bean are configured in the same application context?

    Comment


    • #3
      Marten,

      They are for sure. Here is the complete snippet:

      Code:
                  <context:annotation-config/>
      	<context:mbean-export/>
      
      	<bean id="cacheManagerImpl"
      		class="demo.caching.impl.CacheManagerImpl" />
      
      	<bean id="cacheMBean"
      		class="demo.caching.impl.CacheManagerMBeanImpl" />
      Last edited by difranr; Nov 16th, 2009, 02:05 PM.

      Comment


      • #4
        Hmm... Interesting.

        Instead of the mbean-export and declaring the MBeanExporter try simply adding the AnnotationMBeanExporter.

        Code:
        <bean class="AnnotationMBeanExporter" />
        Do you have other mechanisms in place which for instance proxy the beans in your configuration (like transactions, logging, other aspects/aop beans).

        Comment


        • #5
          Here is my complete config:

          Code:
          <?xml version="1.0" encoding="UTF-8"?>
          
          <beans xmlns="http://www.springframework.org/schema/beans"
          	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          	xmlns:p="http://www.springframework.org/schema/p"
          	xmlns:context="http://www.springframework.org/schema/context"
          	xmlns:jee="http://www.springframework.org/schema/jee"
          	xmlns:tx="http://www.springframework.org/schema/tx"
          	xsi:schemaLocation="
          			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
          			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
          			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
          			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
          
          	<context:annotation-config/>
          	<context:mbean-export/>
            	
          	<bean id="cacheManagerImpl"
          		class="demo.caching.impl.CacheManagerImpl"/>
          
          	<bean id="cacheMBean"
          		class="demo.caching.impl.CacheManagerMBeanImpl"/>
          	
          	<jee:jndi-lookup id="refdataDB" jndi-name="jdbc/referenceData" />
          
          	<bean id="referenceDataLoader"
          		class="demo.referencedata.impl.ReferenceDataCacheLoaderImpl" />
          
          	<!-- Get a cache based on the provided cache loader -->
          	<bean name="referenceDataCache" factory-bean="cacheManagerImpl"
          		factory-method="getCache">
          		<constructor-arg value="referenceData" />
          		<constructor-arg ref="referenceDataLoader" />
          	</bean>
          
          	<bean id="referenceDataManagerImpl"
          		class="demo.referencedata.impl.ReferenceDataManagerImpl" />
          
          	<bean id="jndiTemplate"
          		class="org.springframework.jndi.JndiTemplate">
          		<property name="environment">
          			<props>
          				<prop key="weblogic.jndi.replicateBindings">false</prop>
          			</props>
          		</property>
          	</bean>
          
          	<bean id="controlSystemBinder"
          		class="demo.control.RTMJndiBinder">
          		<property name="jndiObjects">
          			<map>
          				<entry key="rtm/cacheManager"
          					value-ref="cacheManagerImpl" />
          				<entry key="rtm/referenceDataManager"
          					value-ref="referenceDataManagerImpl" />
          			</map>
          		</property>
          		<property name="subContextNames">
          			<list>
          				<value>demo</value>
          			</list>
          		</property>
          	</bean>
          </beans>
          Now I am using the following Context Listener:

          Code:
          <!-- This enables the Spring Console Extensions. -->
          	<listener>
          		<listener-class>weblogic.spring.monitoring.WeblogicContextLoaderListener</listener-class>
          	</listener>
          This is being deployed as a WAR within an EAR.
          Last edited by difranr; Nov 16th, 2009, 03:11 PM.

          Comment


          • #6
            If I use the "old school style" it works just fine as well:

            Code:
            	<!-- This is used to control jmx exporter -->
            	<bean id="exporter"
            		class="org.springframework.jmx.export.MBeanExporter">
            		<property name="assembler" ref="assembler" />
            		<property name="namingStrategy" ref="namingStrategy" />
            		<property name="autodetectModeName"
            			value="AUTODETECT_ASSEMBLER" />
            		<property name="registrationBehaviorName"
            			value="REGISTRATION_IGNORE_EXISTING" />
            	</bean>
            
            	<!-- will create management interface using annotation metadata -->
            	<bean id="assembler"
            		class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
            		<property name="attributeSource" ref="jmxAttributeSource" />
            	</bean>
            
            	<bean id="namingStrategy"
            		class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
            		<property name="attributeSource" ref="jmxAttributeSource" />
            	</bean>
            
            	<!-- annotated MBean support -->
            	<bean id="jmxAttributeSource"
            		class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />

            Comment


            • #7
              I am experiencing the same problem. Using the <context:mbean-export/> shorthand does not seem to work in my Tomcat targeted web app.

              Did you find a solution to your problem? Thanks for sharing this!

              Regards,
              Rik

              Comment


              • #8
                Originally posted by Marten Deinum View Post
                Hmm... Interesting.
                credit card application
                Instead of the mbean-export and declaring the MBeanExporter try simply adding the AnnotationMBeanExporter.

                Code:
                <bean class="AnnotationMBeanExporter" />
                Do you have other mechanisms in place which for instance proxy the beans in your configuration (like transactions, logging, other aspects/aop beans).
                I tried this one. It worked. I don't have other mechanisms in place though.

                Any way thanks for this.

                Regards,

                Comment


                • #9
                  Finally put it together for myself so I'm writing this for the benefit of the community....

                  If you are using the @ManagedResource annotation, the mbean exporter must be initialized PRIOR to the annotation scanner picking up the class. For annotated beans that are initialized on startup, you need to add

                  Code:
                  @ImportResource( "/jmx-config.xml" )
                  @ManagedResource
                  @Component
                  to your class to get the jmx config to be picked up earlier.

                  You can also use the @Configuration syntax to register your mbean exporter ahead of the beans getting instantiated. Just create an @Bean annotated method that emits the annotation exporter.

                  Bottom line, if your exporter is initialized AFTER your beans, you will have a valid jmx context but no beans in it.

                  Comment

                  Working...
                  X