Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JBoss7的附加MBeanServer和JMXConnectorServer_Jboss_Jboss7.x_Jmx_Spring Jmx - Fatal编程技术网

JBoss7的附加MBeanServer和JMXConnectorServer

JBoss7的附加MBeanServer和JMXConnectorServer,jboss,jboss7.x,jmx,spring-jmx,Jboss,Jboss7.x,Jmx,Spring Jmx,由于安全原因,我无法将MBean添加到现有JBoss 7平台MBeanServer。因此,我使用customAuthenticator创建了自己的mBeanServer和JMXConnectorServer 下面是我对新MBeanServer和JMXConnectorServer的Springbean定义。当我在Jetty中运行我的应用程序时,这段代码起作用。我可以通过URL服务进行连接:jmx:rmi://localhost/jndi/rmi://localhost:17999/sample

由于安全原因,我无法将MBean添加到现有JBoss 7平台MBeanServer。因此,我使用
customAuthenticator
创建了自己的mBeanServer和JMXConnectorServer

下面是我对新MBeanServer和JMXConnectorServer的Springbean定义。当我在Jetty中运行我的应用程序时,这段代码起作用。我可以通过URL服务进行连接:jmx:rmi://localhost/jndi/rmi://localhost:17999/sample 在jconsole中,它只显示我所期望的自定义MBean

但同样的代码在JBoss7中不起作用。当我部署到JBoss并尝试使用相同的JMX URL进行连接时,会出现一个对话框,其中有一个错误:“连接到myuser@service:jmx:rmi://localhost/jndi/rmi://localhost:17999/trm 没有成功。您想再试一次吗?”

我在customAuthenticator中设置了一个断点,当我尝试连接JMX时,JBoss不会在断点处停止。我的JMXConnectorServer似乎没有被JBoss使用。有人能帮忙吗?请注意,我无法更改现有JBoss MBeanServer或JMX连接器服务器配置,因为它们用于其他目的

提前谢谢

@Bean
public Object rmiRegistry() throws Exception {
            RmiRegistryFactoryBean factory = new RmiRegistryFactoryBean();
            factory.setPort(17999);
            factory.afterPropertiesSet();
            return factory.getObject();
}

@Bean
@DependsOn("rmiRegistry")
public MBeanServer mBeanServer() {
    MBeanServerFactoryBean factory = new MBeanServerFactoryBean();
    factory.afterPropertiesSet();
    return factory.getObject();
}

@Bean
@DependsOn("rmiRegistry")
public JMXConnectorServer jmxConnectorServer() throws IOException, JMException {
    ConnectorServerFactoryBean factory = new ConnectorServerFactoryBean();
    factory.setServer(mBeanServer());
    factory.setServiceUrl("service:jmx:rmi://localhost/jndi/rmi://localhost:17999/sample");
    factory.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    Map<String, Object> props = new HashMap<>();
    props.put(JMXConnectorServer.AUTHENTICATOR, customAuthenticator);
    factory.setEnvironmentMap(props);
    factory.afterPropertiesSet();

    return factory.getObject();
}

@Bean
@DependsOn("rmiRegistry")
public AnnotationMBeanExporter annotationMBeanExporter() {
    AnnotationMBeanExporter result = null;
    result = new AnnotationMBeanExporter();
    result.setServer(mBeanServer());
    return result;
}
@Bean
公共对象注册表()引发异常{
RmiRegistryFactoryBean工厂=新的RmiRegistryFactoryBean();
工厂设置端口(17999);
factory.AfterPropertieSet();
返回factory.getObject();
}
@豆子
@DependsOn(“注册”)
公共MBeanServer MBeanServer(){
MBeanServerFactoryBean工厂=新的MBeanServerFactoryBean();
factory.AfterPropertieSet();
返回factory.getObject();
}
@豆子
@DependsOn(“注册”)
公共JMXConnectorServer JMXConnectorServer()引发IOException,JMException{
ConnectorServerFactoryBean工厂=新的ConnectorServerFactoryBean();
setServer(mBeanServer());
setServiceUrl(“服务:jmx:rmi://localhost/jndi/rmi://localhost:17999/sample");
factory.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
Map props=newhashmap();
put(JMXConnectorServer.AUTHENTICATOR、customAuthenticator);
factory.setEnvironmentMap(道具);
factory.AfterPropertieSet();
返回factory.getObject();
}
@豆子
@DependsOn(“注册”)
公共注释MBeanExporter注释MBeanExporter(){
AnnotationMBeanExporter结果=null;
结果=新注释MBeanExporter();
result.setServer(mBeanServer());
返回结果;
}

我怀疑JBoss环境正在影响JMX连接器服务器的配置方式。我会尝试额外指定服务侦听端口(例如17998),而不是使用以下JMXServiceURL将其作为临时端口:

service:jmx:rmi://localhost:17998/jndi/rmi://localhost:17999/sample