Pb on using Custom Mbeans in WebSphere6



Hi,

I'm trying to use a MBean I've made inside WAS6. However I've got the
error
message :
<<
javax.management.RuntimeOperationsException: The "name" parameter
cannot be
null. nested runtime exception is java.lang.IllegalArgumentException:
The "name"
parameter cannot be null.
>>

The JAR containing the MBean is installed through the admin console via

"server1 > Admin Services > Extension MBean Provider".

The MBean is accessed via a test servlet.

Is it a normal way to create a customized mbean in WAS 6 ? Why cannot I
see the MBean in the console (text based or mbeaninspector from
developerworks) ?

Bellow are code used in the various components.

Hope somebody already used custom made mbeans in WebSphere and will be
able to answer my question.

Regards,
Blured75.



Here is the xml file used :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MBean SYSTEM "MbeanDescriptor.dtd">
<MBean type="DBOTestMBean">
<operation name="startService" role="operation"
targetObjectType="objectReference" type="void">
<signature/>
</operation>
</MBean>

Here is the java class implementing the mbean :
<<
package com.dbo.test;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.ibm.websphere.management.JMXManageable;

public class DBOTestMBeanImpl implements JMXManageable, DBOTestMBean
{

// CustomService methods
public void initialize(Properties props) throws Exception
{
System.out.println("DBOTestMBeanImpl.initialize("+props+")");
startService();
}
public void shutdown()
{
System.out.println("DBOTestMBeanImpl.shutdown()");
}

public void startService() {
System.out.println("begin DBOTestMBeanImpl.startService()");

try {
Context ctx = new InitialContext();
System.out.println("in the startservice of DBOTestMBeanImpl.java
!");

}
catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("end DBOTestMBeanImpl.startService()");
}

// JMXManageable methods
public String getType()
{
System.out.println("DBOTestMBeanImpl.getType()"); return
"DBOTestMBean";
}
public Properties getMBeanProperties()
{
System.out.println("DBOTestMBeanImpl.getMBeanProperties()");
Properties props = new Properties();
props.put("Identification", "DBOTestMBean");
return props;
}
}
>>

Here is the interface used :
<<
package com.dbo.test;
/**
* MBean interface.
*/
public interface DBOTestMBean {
public void startService();
}
>>

Here is the code snippet from the servlet used to call the MBean :
<<
MBeanFactory mbfactory = AdminServiceFactory.getMBeanFactory();
System.out.println("before");

//mbfactory.

mbfactory.completeActivateMBeans();

List aList = mbfactory.getMBeanTypes();
Iterator itList = aList.iterator();
while (itList.hasNext()) {
System.out.println("itList.next() " + itList.next());
}


ObjectName on2 = null;

try {
on2 = new
ObjectName("WebSphere:cell=websphereNode02Cell,mbeanIdentifier=DBOTestMBean,name=DBOTestMBean,node=websphereNode02,process=server1,type=DBOTestMBean,version=6.0.2.1");
}
catch (Exception ex) {
System.out.println("Exception sur la création de l'object name
DBO Test MBean");
ex.printStackTrace();
}

String opName = "startService";
String signature[] = { };
String params[] = { };
try
{
AdminServiceFactory.getAdminService().invoke(on2, opName, params,
signature);
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception invoking launchProcess: " + e);

}
>>

.