Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-beta-1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:WebSphere version 5.02
-
Number of attachments :
Description
MBean registration fails for components without domain specification.
To figure out what went wrong I updated NanoMxRegistrationException so it has all constructors from its super class and updated both NanoMxContainer:
public synchronized void registerComponentInstance(Object key, Object component)
throws PicoRegistrationException {
ObjectName name = null;
try
catch (InstanceAlreadyExistsException e)
{ throw new NanoMXRegistrationException("Failed to register MBean '" + name + "' for component '" + key + "', due to " + e.getMessage(), e); }catch (MBeanRegistrationException e)
{ throw new NanoMXRegistrationException("Failed to register MBean '" + name + "' for component '" + key + "', due to " + e.getMessage(), e); } catch (NotCompliantMBeanException e) { throw new NanoMXRegistrationException("Failed to register MBean '" + name + "' for component '" + key + "', due to " + e.getMessage(), e); }catch (MalformedObjectNameException e)
{ throw new NanoMXRegistrationException("Failed to register MBean '" + name + "' for component '" + key + "', due to " + e.getMessage(), e); } catch (PicoRegistrationException e) { throw new NanoMXRegistrationException("Failed to register MBean '" + name + "' for component '" + key + "', due to " + e.getMessage(), e); }}
and updated NanoMxComponentAdapter:
public Object getComponentInstance(MutablePicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException {
if (componentInstance == null) {
componentInstance = super.getComponentInstance(picoContainer);
ObjectName name = null;
try
catch (MalformedObjectNameException e)
{ throw new NanoMXInitializationException("Failed to register MBean '" + name + "' for component '" + getComponentKey() + "', due to " + e.getMessage(), e); } catch (MBeanRegistrationException e) { throw new NanoMXInitializationException("Failed to register MBean '" + name + "' for component '" + getComponentKey() + "', due to " + e.getMessage(), e); }catch (NotCompliantMBeanException e)
{ throw new NanoMXInitializationException("Failed to register MBean '" + name + "' for component '" + getComponentKey() + "', due to " + e.getMessage(), e); } catch (InstanceAlreadyExistsException e) { throw new NanoMXInitializationException("Failed to register MBean '" + name + "' for component '" + getComponentKey() + "', due to " + e.getMessage(), e); } return componentInstance;
}
return componentInstance;
}
so they throw more detailed exception messages.
When it was clear what was wrong, I also updated the NanoMxComponentAdapter' asObjectName() to the following:
public static ObjectName asObjectName(Object key) throws MalformedObjectNameException {
if (key == null)
if (key instanceof ObjectName)
{ return (ObjectName) key; }if (key instanceof Class)
{ Class clazz = (Class) key; return new ObjectName("nanomx:type=" + clazz.getName()); } else {
String text = key.toString();
// Fix, so it works under WebSphere ver. 5
if (text.indexOf(':') == -1)
return new ObjectName(text);
}
}
/Jeppe
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | NanoMXFix.zip [ 10921 ] |
Resolution | Fixed [ 1 ] | |
Status | Unassigned [ 1 ] | Closed [ 6 ] |
Complete sourcecode for the fixes.