I've been testing hot deploying and undeploying Geronimo services and something odd is going on. I've spent most of the weekend looking at this and not getting any further, so any JMX/MX4J experts out there feel free to respond :-)

Essentially, the situation is this:
 + in the preRegister() method for an AbstractManagedObject, the object
   signs itself up to listen for MBean registration notifications
   from the mbean "JMImplementation:type=MBeanServerDelegate"

 + whenever it receives an mbean registration notification, it
   automatically adds itself as a listener for futher event types
   (o.a.g.kernel.management.NotificationType.NOTIFICATION_FILTER)

 + when an AbstractManagedObject is registered, it seems to receive
   registration notifications for itself, so these are ignored

Now, if I undeploy the service, then the mbean for the service is unregistered as expected. But, when I re-deploy the service, not only does the AbstractManagedObject receive registration events for itself as before, but it receives duplicates of them like this:

[java] Creating MBean=blah:role=Blah
[java] -400856369:::: Received registration notification for blah:role=Blah
[java] 18:41:11,646 DEBUG [Blah] blah:role=Blah Notified of my own registration
[java] 18:41:11,646 DEBUG [InterceptorRegistryRouter] Adding notificationlistener for blah:role=Blah from geronimo.remoting:router=InterceptorRegistryRouter
[java] -400856369:::: Received registration notification for blah:role=Blah
[java] 18:41:11,952 DEBUG [Blah] blah:role=Blah Notified of my own registration
[java] Registered MBean=blah:role=Blah



I initially thought the duplicates might be due to the AbstractManagedObject not explicitly removing itself from the mbean server as a notification listener when it is destroyed, so I tried adding a removeNotificationListener() call in the AbstractManagedObject's preDeregister() method, but that always throws an exception like so:
[java] 19:36:17,868 ERROR [Blah] javax.management.ListenerNotFoundException: NotificationListener [EMAIL PROTECTED] not found


The truly freaky thing is that once any service has been thru the deploy/undeploy/redeploy cycle, any OTHER service that is subsequently deployed also receives duplicate notifications, even if it has never previously been deployed!!!

I've attached some very simple classes and a service file that can be dropped into the deploy/jetty directory that illustrates the problem.

Any help gratefully received.

Jan


/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in
*    the documentation and/or other materials provided with the
*    distribution.
*
* 3. The end-user documentation included with the redistribution,
*    if any, must include the following acknowledgment:
*       "This product includes software developed by the
*        Apache Software Foundation (http://www.apache.org/)."
*    Alternately, this acknowledgment may appear in the software itself,
*    if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
*    "Apache Geronimo" must not be used to endorse or promote products
*    derived from this software without prior written permission. For
*    written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
*    "Apache Geronimo", nor may "Apache" appear in their name, without
*    prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation.  For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/


package org.apache.geronimo.web;

import java.awt.Component;

import javax.management.Attribute;
import javax.management.MBeanServerNotification;
import javax.management.Notification;
import javax.management.ObjectName;

import org.apache.geronimo.core.service.AbstractManagedContainer;
import org.apache.geronimo.kernel.service.AbstractManagedObject;

/* -------------------------------------------------------------------------------------- */
/**
 * Blah
 * 
 * @jmx:mbean extends="org.apache.geronimo.core.service.ManagedContainer, org.apache.geronimo.kernel.management.StateManageable, javax.management.MBeanRegistration
 * @version $Revision: $ $Date: $
 */
public class Blah extends AbstractManagedContainer implements BlahMBean
{
    public Blah (){
    }
    
    public void handleNotification (Notification n, Object o){
         
                if (MBeanServerNotification .REGISTRATION_NOTIFICATION.equals(n.getType()))
                {
                    MBeanServerNotification notification =
                        (MBeanServerNotification) n;
                    ObjectName source = notification.getMBeanName();
                  
                       System.out.println ( this.hashCode()+":::: Received registration notification for "+ source);
                       
                       if (o instanceof Component)
                       {
                           try
                           {
                               server.setAttribute (source, new Attribute("Container", this));
                           }
                           catch (Exception e)
                           {
                               e.printStackTrace();
                           }
                       }
                }
                
                super.handleNotification (n, o);
    }
    
    /*
    public void doStart () {
        System.out.println ("BLAH STARTED");
    }
    
    
    public void doStop () {
        System.out.println ("BLAH STOPPED");
    }
    
    */
}
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in
*    the documentation and/or other materials provided with the
*    distribution.
*
* 3. The end-user documentation included with the redistribution,
*    if any, must include the following acknowledgment:
*       "This product includes software developed by the
*        Apache Software Foundation (http://www.apache.org/)."
*    Alternately, this acknowledgment may appear in the software itself,
*    if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
*    "Apache Geronimo" must not be used to endorse or promote products
*    derived from this software without prior written permission. For
*    written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
*    "Apache Geronimo", nor may "Apache" appear in their name, without
*    prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation.  For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/


package org.apache.geronimo.web;

import org.apache.geronimo.core.service.AbstractManagedComponent;
import org.apache.geronimo.core.service.Container;

/* -------------------------------------------------------------------------------------- */
/**
 * BlahComponent
 * 
 * @jmx:mbean extends="org.apache.geronimo.core.service.ManagedComponent, org.apache.geronimo.kernel.management.StateManageable, javax.management.MBeanRegistration
 * @version $Revision: $ $Date: $
 */
public class BlahComponent extends AbstractManagedComponent implements BlahComponentMBean
{
    public BlahComponent()
    {}
    
    public void setContainer (Container c)
    {
        System.out.println ("setContainer() called with container="+c);
        super.setContainer(c);
    }

}
<?xml version="1.0" encoding="UTF-8"?>
<components>

    <!-- ================================================================ -->
    <!-- Set up the Jetty-specific jars                                   -->
    <!-- ================================================================ -->
    <class-space name="geronimo.system:role=ClassSpace,name=Blah">
        <codebase url="file:lib/">
            <archive name="*"/>
        </codebase>
	<codebase url="file:../../lib/">
	    <archive name="geronimo-core-DEV.jar"/>
	    <archive name="geronimo-common-DEV.jar"/>
	</codebase>
    </class-space>

    <mbean code="org.apache.geronimo.web.Blah" 
           name="blah:role=Blah">
    </mbean>

<!--
    <mbean code="org.apache.geronimo.web.BlahComponent"
           name="blah:role=BlahComponent">
    </mbean>
-->
</components>

Reply via email to