4

我正在尝试按照此处给出的 Jolokia Spring 支持参考文档在 Spring 应用程序中配置 Jolokia JVM 代理。

我已添加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/

以及列出代理及其正确端口 15000 的 hawtio。

我还尝试按照参考文档中的建议在不使用 Jolokia 命名空间的情况下重写 Spring 配置,例如:

<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>

但这仍然会带来同样的问题。

所以我的问题是,我在导致 Jolokia 代理失败的 Spring 配置中做错了什么?

有关信息,我的 Spring 版本是 4.1.6,JDK 是 1.8.0_45。

谢谢

4

0 回答 0