简体   繁体   中英

Spring with JMX authentication

I can register a Class into MBean but could not connect via jconsole. Why I could not connect running this application though I have disabled the jmx authentication via JVM parameters.

Here is my java Classes, spring property file and JVM parameters

package com.mkyong.jmx;

public interface JmxCoreComands {
    public void start();
    public void stop();
    public void report();   
}


package com.mkyong.jmx;

import org.springframework.stereotype.Service;

@Service
public class JmxService implements JmxCoreComands {

    @Override
    public void start() {
        System.out.println("Jmx Service start");
    }

    @Override
    public void stop() {
        System.out.println("jmx service stop");
    }

    @Override
    public void report() {
        System.out.println("jmx service report");
    }

}

Spring property XML:

<bean id="jmxAdapter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
        <property name="beans">
            <map>
                <entry key="SPRING:Name=TestRun">
                    <ref bean="jmxService" />
                </entry>
            </map>
        </property>
        <!-- managemethods property starts -->
        <property name="assembler">
            <bean
                class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
                <property name="managedInterfaces">
                    <value>com.mkyong.jmx.JmxCoreComands</value>
                </property>
            </bean>
        </property>
        <!-- managemethods property ends -->
    </bean>

JVM Parameters:

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8014 
-Dcom.sun.management.jmxremote.authenticate=false 
-Xmx1024M 
-Xdebug 
-Xnoagent 
-Xrunjdwp:transport=dt_socket,address=8454,server=y,suspend=n 
-Djava.compiler=NONE

After changed my JVM configuration as following I am able to connect the application over JMX.

-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote.port=8014
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM