在WebSphere服务器中部署时,MBean未显示在jconsole中

时间:2018-06-18 05:49:10

标签: java websphere jconsole spring-jmx

在websphere中, 我试图通过jconsole将spring bean注册为JMX bean,但无法使其工作。

服务器参数: -Djavax.management.builder.initial = -Dcom.sun.management.jmxremote = true -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.ssl = false -Dcom.sun.management。 jmxremote.port = 5555 -Dcom.sun.management.jmxremote.autodiscovery = true

TestNotificationPublisher.java

@ManagedResource(objectName = "test.jmx.publisher:name=testNotificationPublisher", description = "testNotificationPublisher")
public class TestNotificationPublisher implements NotificationPublisherAware {

   private static Logger         logger    = Logger.getLogger( TestNotificationPublisher.class.getName() );
   private NotificationPublisher notificationPublisher;
   private long                  seqNumber = 0;
   private ObjectMapper          mapper    = new ObjectMapper();

   public void publish( String notficationType, Object obj ) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException {


      try {
         this.notificationPublisher.sendNotification( new Notification( notficationType, this, seqNumber++, System.currentTimeMillis(), mapper.writeValueAsString( obj ) ) );
      }
      catch( UnableToSendNotificationException e ) {
         logger.log( Level.SEVERE, e.getMessage(), e );
      }
      catch( JsonProcessingException e ) {
         logger.log( Level.SEVERE, e.getMessage(), e );
      }
   }

的applicationContext.xml

<?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:context="http://www.springframework.org/schema/context"
       xmlns:si="http://www.springframework.org/schema/integration"
       xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/integration
            http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/integration/jmx
            http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">

    <context:mbean-server/>
    <context:mbean-export/>

    <bean id="testNotificationPublisher" class="com.test.jmx.publisher.TestNotificationPublisher" scope="prototype"/>
</beans>

在weblogic或tomcat中部署相同的代码时,mconsole中会显示mbean。但是当部署在websphere时,它通过jconsole连接但没有显示这个创建的mbean。见下图enter image description here 有人可以帮助我缺少什么或为什么mbean没有在websphere中部署时出现在jconsole中?

0 个答案:

没有答案