# Using the MC4J JMX Console

This guide describes how to use the MC4J JMX Console to administrate a JOnAS server. In order to use MC4J, the JOnAS server must be configured to use MX4J as JMX implementation for its Jmx service. See the JMX service configuration instructions in the Configuring JOnAS services documentation chapter.

Note that JOnAS delivery contains the MX4J jar files, but you have to download MC4J from the SourceForge site.

In order to administrate a JOnAS server with MC4J, you must create a connection to the JMX server launched by the Jmx service at JOnAS starting time.

Here after is described how to create a connection to the JMX server. Once the connection created, you can browse the MBeans registered in the JMX server, view their exposed attributes and invoke the administration operations supported by them.

1. Connecting to the JMX server
2. Administering the JOnAS server

## Connecting to the JMX server

1. Check the JOnAS configuration with the jonas check command. You should verify the followings:
   - the `jonas.services` property contains jmx in the services list.
   - the jonas.service.jmx.class property is set to `org.objectweb.jonas.jmx.mx4j.Mx4jJmxServiceImpl`
2. Start the JOnAS server using the jonas start command.
   When starting the JOnAS server, the Jmx service creates an MBean server and starts an MX4J JRMP adaptor. This adaptor is exposed by registering it in the JOnAS Registry service. The used JNDI name is constructed with the following pattern:
   - `RMIConnector_`jonas-server-name
   where the jonas-server-name is the value of the `jonas.name` property is `jonas.properties` file.
3. Launch the MC4J console.
4. Select "MC4J for MX4J" from the explorer tab. Right-click on the root node and select "Connect.." to open the connection dialog. Then, provide the required parameters:
   - Choose a name for the connection
   - JNDI Name: follow the above presented pattern
   - Initial Context Factory: should be consistent with your `jndi.properties` file
   - Server URL: provide the JOnAS Registry URL (cf. `jndi.properties`)

## Administering the JOnAS server

Let's suppose you compiled and installed the JOnAS provided example samples and you launched a JOnAS server in `$JONAS_ROOT/examples/src/sb/`.
When browsing the jonas folder, you can see the followings:

- a MBean corresponding to the SessionBean loaded from `sb.jar`
- a MBean corresponding to the container containing the SessionBean
- the JRMP adaptor
- Mbeans corresponding to resources, like Mail Factories
- Mbeans corresponding to the JOnAS services

Suppose you need to load the `eb.jar` sample. Use the MBean corresponding to the EJB Container service: `name=ejbContainer,type=service`. Choose the `createContainer` operation from the `Operations` list and run the action. You must provide one parameter (`param1`): the name of the file to load (`eb.jar`).

### Customization of the managed beans

In order to facilitate the use of a generic management console like MC4J, we could use the customization facilities offered by MX4J described in this products documentation. This implies writing `MBeanDescrition` classes for the MBeans. Note also that MX4J includes a jar for the XDoclet tool allowing for generate source code of MBean interfaces and descriptions. This jar is not included in the current JOnAS delivery.