Feed on
 Posts
 Comments
Java Beans dot Asia

Just a few simple tutorials …

Few days ago i came across a little nasty thing during mbean deployment. What I did was separation of my mbean class and its interface in to two archives. So first i would deploy an archive contained my interfaces and then i would deploy an archive contained my bean classes.

Why did i do it this way?

Well to minimize chances having ClassCastException. Since JBoss creates a proxy to the bean from its interface. Having the interfaces deployed seperately from the bean itself, allows me easily to modify business logic in the bean (if needed). Therefore, I will have to redeploy only the bean itself, without the need to redeploy also the interface, which will not affect my proxies to the bean in the system.

To my big surprise i got an exception:

	org.jboss.deployment.DeploymentException: Class does not expose a management interface:
	java.lang.Object; - nested throwable:
	(javax.management.NotCompliantMBeanException:Class does not expose a management interface: java.lang.Object)

I could not understand where did I go wrong. I had my mbean class:

public class MyService 	extends ServiceMBeanSupport implements MyServiceMBean {

	public void startService() throws Exception {
		...
	}

	public void stopService() {
		...
	}
}

I had my interface with extension ‘MBean’. The interface must have this extension, otherwise, you will receive a Class does not expose a management interface exception :

	public interface MyServiceMBean extends ServiceMBean {	...}

I had my jboss-service.xml:

	<?xml version="1.0" encoding="UTF-8"?>
		<server>
			<mbean code="com.example.MyService" name="com.example:service=MyService">
			</mbean>
		</server>

Finally, i discovered that it was because of the way i did the packaging. If you ever going to package mbean and its interface in two separate archives, they (mbean and its interface) must sit under the same package name!

For example: if I in archive A, put my mbean class under the package name “com.example.test“, then in archive B I have to put its interface also under “com.example.test“.

GD Star Rating
loading...

Related posts:

  1. JBoss Clustering – How Many Nodes in the Cluster?
    If you want to know how many nodes there are in the current cluster partition, all you have to do is to ask...
  2. JBoss Clustering – Shared State Across Cluster Partition
    Did you know that if you have a JBoss cluster, HA singletons service beans on each can share a common memory state? State...
  3. JBoss Clustering Architecture – Distributed Replicant Manager
    My understanding of Distributed Replicant Manager (DRM) is that it allows you to attach some serialized data (stub) to a cluster node and...
  4. JBoss Clustering – HASingleton Service
    Have you ever dealt with clustered singleton service? How to determine which cluster node is the master? Well, if I am the current...
  5. Using Template to Deploy a JBoss Queue
    Currently I am involved in a project, where I have to use Velocity template engine to deploy queues and message-driven beans to JBoss....