2 Replies Latest reply on Jun 27, 2012 8:00 AM by nicolas duminil

    javax.naming.NameAlreadyBoundException in route

    nicolas duminil Expert

      Greetings,

       

      I'm trying to cyclicly sample some of the MBean exposed by Camel. The route is the following:

       

        ();

          env.put(JMXConnector.CREDENTIALS, new String[]

          { "smx", "smx" });

          JMXConnector jmxc = JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root"), env);

          MBeanServerConnection server = jmxc.getMBeanServerConnection();

          ObjectName objName = new ObjectName("org.apache.camel:type=routes,name=\"\",");

          List(server.queryNames(objName, null));

          for (ObjectName objName2 : cacheList)

            for (String op : ops)

            {

              Object o = server.invoke(objName2, "get" + op, null, null);

              if (o != null)

              {

                EventObject eo = new EventObject(o);

                jnen.notify(eo);

              }

            }

          return "done";

        }

       

      But before the route starts, the following exception is raised:

       

      java.io.IOException: Cannot bind to URL rmi://dow-jones:1099/jmxrmi/camel: javax.naming.NameAlreadyBoundException: jmxrmi/camel Root exception is java.rmi.AlreadyBoundException: jmxrmi/camel

           at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)[:1.6.0_31]

           at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417)[:1.6.0_31]

           at org.apache.camel.management.DefaultManagementAgent$1.run(DefaultManagementAgent.java:424)[camel-core-2.9.0.fuse-7-061.jar:2.9.0.fuse-7-061]

           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_31]

           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_31]

           at java.lang.Thread.run(Thread.java:662)[:1.6.0_31]

       

      Further, the route works correctly. What could be wrong here ?

       

      Many thanks in advance,

       

      Nicolas