Manage Servlet/EJB with JMX and J2EE Management
wengatz_n Nov 24, 2003 5:47 AMHi,
I have some questions to the usage of JMX in a Servlet/EJB deployed in the JBOSS.
In addition to the lifecycle methods (start, stop ...) I would like to manage some
application specific parameters (f.e. method setNumber to set a value in my application).
1)
I started with the following steps:
a) Develop a 'normal' test servlet named NicoleTester (without any JMX specific code)
b) Deploy it in JBOSS (Version 3.2.2)
c) Click on link J2EEApplication=null,J2EEServer=Local,WebModule=jmx-console.war,j2eeType=Servlet,name=NicoleTester
in the jmx-console
Here I get methods to start, stop my Servlet, but I seems as they are not working. Even after stopping the servlet
I'm able to invoke it ??? What is wrong here ?
******************************************************************************************************************
2)
In a second step a defined an interface
public interface NicoleTesterMBean {
public void setNumber(int number);
}
and let my servlet register as MBean in the init-method:
public class NicoleTester extends HttpServlet implements NicoleTesterMBean {
int mNumber=0;
public void init(ServletConfig aConfig){
MBeanServer m;
List list=MBeanServerFactory.findMBeanServer(null);
m=(MBeanServer)list.iterator().next();
try{
ObjectName name=new ObjectName("example:name=Nicoles_MBean");
m.registerMBean(this,name);
} catch (Exception e){
e.printStackTrace();
}
}
...
This works fine, via the jmx-console I can set my number.
But in the Nicoles_MBean view I can only manage the method setNumber, no lifecycle methods.
The MBean view J2EEApplication=null,J2EEServer=Local,WebModule=jmx-console.war,j2eeType=Servlet,name=NicoleTester
is still available, but still nothing happens when I click on start, stop, destroy.
How can I get the second view to work and how can I merge the two views ?
*******************************************************************************************************************
3)
Now I modified the interface:
public interface NicoleTesterMBean extends ServletMBean {
public void setNumber(int number);
}
and implemented the required methods stop, start, isEventProvider ... in my Servlet class.
In the jmx-console however the lifecycles methods will not be displayed. How can I invoke them or
when will they be invoked ?
I tried the start/stop methods of the
MBean view J2EEApplication=null,J2EEServer=Local,WebModule=jmx-console.war,j2eeType=Servlet,name=NicoleTester, but
my methods were not be invoked.
Could you please explain me the meaning of the MBean J2EEApplication=null,J2EEServer=Local,WebModule=jmx-console.war,j2eeType=Servlet,name=NicoleTester
and provide me with a solution/idea how I can mange lifecycle and application specific methods (like setNumber)
of my servlet?
Thanks a lot and best regards
Nicole