I am attempting to configure a Jolokia JVM agent in a Spring application by following the reference documentation for Jolokia Spring support given here.
I have added jolokia-spring-1.3.1
as a maven dependency, and below is my spring application context:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jolokia="http://www.jolokia.org/jolokia-spring/schema/config"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.jolokia.org/jolokia-spring/schema/config http://www.jolokia.org/jolokia-spring/schema/config/jolokia-config.xsd">
<jolokia:agent>
<jolokia:config host="localhost" port="15151" debug="true" />
</jolokia:agent>
Running the code gives the following output on the console, however no Jolokia agent is created:
I> No access restrictor found, access to all MBean is allowed
I> Cannot join multicast group on NIF utun0: Can't assign requested address
I> Cannot join multicast group on NIF awdl0: Can't assign requested address
D> /192.168.1.247<-- Listening for queries
D> /192.168.1.247<-- Waiting
I> Cannot join multicast group on NIF utun0: Can't assign requested address
I> Cannot join multicast group on NIF awdl0: Can't assign requested address
D> /127.0.0.1<-- Listening for queries
D> /127.0.0.1<-- Waiting
Browsing to http://127.0.0.1:15151/jolokia/
shows the following:
{"request":{"type":"version"},"value":{"agent":"1.3.1","protocol":"7.2","config":{"maxDepth":"15","discoveryEnabled":"true","maxCollectionSize":"0","agentId":"192.168.1.247-3124-78dd667e-jvm","debug":"true","agentType":"jvm","historyMaxEntries":"10","agentContext":"\/jolokia","maxObjects":"0","debugMaxEntries":"100"},"info":{}},"timestamp":1434904598,"status":200}
Using hawtio to list the available JVMs shows the JVM created, but is blank under 'Agent URL'. Attempting to start an agent in hawtio gives the following error on the console:
I> jolokia:type=Config is already registered. Adding it with jolokia:type=Config,uuid=8bd5c6d9-cbf0-4569-b588-087f5c41522e, but you should revise your setup in order to either use a qualifier or ensure, that only a single agent gets registered (otherwise history functionality might not work)
If instead of using spring XML, I run the code with the following java option:
-javaagent:/Users/steve/jolokia-jvm-1.3.1-agent.jar=port=15000
Then the agent is correctly started and available, and this is confirmed by the following console output:
I> No access restrictor found, access to all MBean is allowed
I> Cannot join multicast group on NIF utun0: Can't assign requested address
I> Cannot join multicast group on NIF awdl0: Can't assign requested address
I> Cannot join multicast group on NIF utun0: Can't assign requested address
I> Cannot join multicast group on NIF awdl0: Can't assign requested address
Jolokia: Agent started with URL http://127.0.0.1:15000/jolokia/
As well as hawtio listing the agent and its correct port, 15000.
I have also tried re-writing the Spring config without using the Jolokia namespace as suggested in the reference documentation, for example:
<bean name="server" id="jolokia" class="org.jolokia.jvmagent.spring.SpringJolokiaAgent">
<property name="lookupConfig" value="false"/>
<property name="systemPropertiesMode" value="never"/>
<property name="config">
<bean class="org.jolokia.jvmagent.spring.SpringJolokiaConfigHolder">
<property name="config">
<util:map>
<entry key="autoStart" value="true"/>
<entry key="host" value="0.0.0.0"/>
<entry key="port" value="15151"/>
</util:map>
</property>
</bean>
</property>
but this still gives the same problems.
So my question is, what am I doing wrong in the Spring config that is causing Jolokia agent to fail?
For information my Spring version is 4.1.6 and JDK is 1.8.0_45.
Thanks