我正在尝试在Spring应用程序中配置Jolokia JVM代理,方法是遵循here给出的Jolokia Spring支持的参考文档。
我添加了jolokia-spring-1.3.1
作为maven依赖项,下面是我的spring应用程序上下文:
<?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>
运行代码会在控制台上显示以下输出,但不会创建Jolokia代理:
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
浏览到http://127.0.0.1:15151/jolokia/
会显示以下内容:
{"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}
使用hawtio列出可用的JVM显示了创建的JVM,但在“代理URL”下是空白的。尝试在hawtio中启动代理程序会在控制台上出现以下错误:
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)
如果不是使用spring XML,而是使用以下java选项运行代码:
-javaagent:/Users/steve/jolokia-jvm-1.3.1-agent.jar=port=15000
然后代理正确启动并可用,这由以下控制台输出确认:
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/
除了hawtio列出代理及其正确的端口,15000。
我还尝试重新编写Spring配置,而不使用参考文档中建议的Jolokia命名空间,例如:
<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>
但这仍然会产生同样的问题。
所以我的问题是,我在Spring配置中做错了什么导致Jolokia代理失败?
有关信息,我的Spring版本是4.1.6,JDK是1.8.0_45。
由于