Friday, February 13, 2009

Install jManage Application Management Platform as a service

You can find a detailed explanation at Vigil Bose's blog site.

Has anyone tried setting up jManage as a service on windows or linux?

Generating alerts from your Java application

You can very easily setup your application to emit MBean notification in case of a severe error. Here is some sample code:


public class AlertNotification
extends NotificationBroadcasterSupport
implements AlertNotificationMBean {

private static final String TYPE_SEVERE = "SEVERE";
private int sequence = 1;
private static AlertNotification instance =
new AlertNotification();

public static AlertNotification getInstance() {
return instance;
}

private AlertNotification() {
}

public MBeanNotificationInfo[] getNotificationInfo() {
MBeanNotificationInfo[] notifications =
new MBeanNotificationInfo[1];
notifications[0] =
new MBeanNotificationInfo(new String[] { TYPE_SEVERE },
"LogNotification",
"Types of notifications emitted by this broadcaster");
return notifications;
}

public void send(String message) {
this.sendNotification(new Notification(TYPE_SEVERE, this,
sequence++, System.currentTimeMillis(), message));
}
}


Also remember to register the MBean above:


MBeanServer mbeanServer =
ManagementFactory.getPlatformMBeanServer();
mbeanServer.registerMBean(
AlertNotification.getInstance(),
new ObjectName(ObjectNames.ALERT_NOTIFICATION_BEAN));


The code above will emit a MBean notification when the send() method is called. For example:


AlertNotification.getInstance().send("your alert message here");


You can then configure jManage to listen to this MBean notification and generate an alert that can be delivered to your mail box. To learn more about configuring alerts in jManage see jManage Documentation.

Please let me know what you think of the code above. Also, please share if you have setup something like this with jManage.

Wednesday, February 11, 2009

Problem with connecting to JBoss on remote linux machine

Just resolved a problem where jManage was not able to connect to JBoss instance on a remote box. The /etc/hosts file on the remote box had:


127.0.0.1 localhost uat2 uat2.carezen.local


After, changing the hosts file to:


127.0.0.1 localhost
10.10.1.51 uat2 uat2.carezen.local


and restarting the JBoss instance, the problem got resolved.

Please be aware of this issue. Other users have run into it as well. There is also a reference to this issue on JBoss forum.

Also note that this problem also occurs with JSR160 connections, e.g. connecting to JVM.