Modified: trunk/core/src/main/java/org/servicemix/jbi/management/ManagementContext.java (687 => 688)
--- trunk/core/src/main/java/org/servicemix/jbi/management/ManagementContext.java 2005-10-27 08:50:04 UTC (rev 687)
+++ trunk/core/src/main/java/org/servicemix/jbi/management/ManagementContext.java 2005-10-27 15:00:38 UTC (rev 688)
@@ -56,7 +56,8 @@
/**
* Default servicemix domain
*/
- public static String DEFAULT_DOMAIN = "org.servicemix";
+ public static final String DEFAULT_DOMAIN = "org.servicemix";
+
private final static Log log = LogFactory.getLog(ManagementContext.class);
private JBIContainer container;
private MBeanServer beanServer;
@@ -214,6 +215,11 @@
}
}
if (locallyCreateMBeanServer && beanServer != null) {
+ try {
+ beanServer.invoke(ObjectName.getInstance("naming:type=rmiregistry"), "stop", null, null);
+ } catch (Exception e) {
+ log.debug("Could not stop naming service", e);
+ }
// check to see if the factory knows about this server
List list = MBeanServerFactory.findMBeanServer(null);
if (list != null && !list.isEmpty() && list.contains(beanServer)) {
@@ -575,14 +581,6 @@
if (list != null && list.size() > 0) {
result = (MBeanServer) list.get(0);
}
- // As we are here - make sure a registry is loaded
- try {
- LocateRegistry.createRegistry(namingPort);
- }
- catch (Throwable e) {
- // proably exists already
- log.debug("Failed to create local registry", e);
- }
if (result == null && createMBeanServer) {
result = MBeanServerFactory.createMBeanServer(jmxDomainName);
locallyCreateMBeanServer = true;
@@ -590,7 +588,11 @@
ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
if (!result.isRegistered(namingName)) {
try {
- result.createMBean("mx4j.tools.naming.NamingService", namingName, null);
+ // Do not use the createMBean as the mx4j jar may not be in the
+ // same class loader than the server
+ Class cl = Class.forName("mx4j.tools.naming.NamingService");
+ result.registerMBean(cl.newInstance(), namingName);
+ //result.createMBean("mx4j.tools.naming.NamingService", namingName, null);
// set the naming port
Attribute attr = new Attribute("Port", new Integer(namingPort));
result.setAttribute(namingName, attr);
@@ -598,7 +600,15 @@
}
catch (Exception e) {
// could already be in use
- log.debug("invoke failed", e);
+ log.debug("Could not start naming service", e);
+ // Now, make sure a registry is loaded
+ try {
+ LocateRegistry.createRegistry(namingPort);
+ }
+ catch (Throwable t) {
+ // proably exists already
+ log.debug("Failed to create local registry", t);
+ }
}
JMXServiceURL url = "" JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + namingPort
+ jndiPath);