Forum Home » Fuse Distributions » Fuse ESB

Thread: javax.naming.NameAlreadyBoundException in route

 
This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Jun 27, 2012 12:00 PM Last Post By: nicolasduminil
nicolasduminil

Posts: 87
Registered: 02/24/09
javax.naming.NameAlreadyBoundException in route
Posted: Jun 26, 2012 4:53 PM
 
  Click to reply to this thread Reply
Greetings,

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

<camelContext managementNamePattern="#name#" id="monitoringContext" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" statisticsLevel="All" />
<route>
<from uri="timer:foo?period=60s" />
<setBody>
<method method="getMetrics" ref="monitoringMBean"></method>
</setBody>
<log message="A monitoring cycle has been performed" />
</route>
</camelContext>

and the Java code is like that:

public String getMetrics() throws Exception
{
Hashtable<String, String]> env = new Hashtable<String, String[>();
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<ObjectName> cacheList = new LinkedList<ObjectName>(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
njiang

Posts: 572
Registered: 09/17/07
Re: javax.naming.NameAlreadyBoundException in route
Posted: Jun 27, 2012 1:27 AM   in response to: nicolasduminil in response to: nicolasduminil
 
  Click to reply to this thread Reply
It looks like you are deploying the camel route into the karaf.
And Camel is trying to create a rmi connector with default port to use.

You may disable it by changing the jmxAgent definition like this
<jmxAgent id="agent" createConnector="false" statisticsLevel="All" />

Willem

nicolasduminil

Posts: 87
Registered: 02/24/09
Re: javax.naming.NameAlreadyBoundException in route
Posted: Jun 27, 2012 12:00 PM   in response to: njiang in response to: njiang
 
  Click to reply to this thread Reply
Hi Willem,

Many thanks for your help.

Nicolas