2014-11-12 2 views
0

임베디드 -jmxtrans를 사용하여 기본적인 시작 예제를 시험해보고 싶었습니다. 그래서 아래의 코드를 추가임베디드 JMXTrans 스프링 구성

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jmxtrans="http://www.jmxtrans.org/schema/embedded" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.jmxtrans.org/schema/embedded http://www.jmxtrans.org/schema/embedded/jmxtrans-1.0.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <context:annotation-config/> 

    <jmxtrans:jmxtrans> 
     <jmxtrans:configuration>classpath:jvmmonitoring/jmxtrans/jmxtrans.json</jmxtrans:configuration> 
     <jmxtrans:configuration>classpath:org/jmxtrans/embedded/config/tomcat-6.json</jmxtrans:configuration> 
     <jmxtrans:configuration>classpath:org/jmxtrans/embedded/config/jmxtrans-internals.json</jmxtrans:configuration> 
     <jmxtrans:configuration>classpath:org/jmxtrans/embedded/config/jvm-sun-hotspot.json</jmxtrans:configuration> 
    </jmxtrans:jmxtrans> 


</beans> 

public class EmbeddedJMXTrans { 
    public static void main(String[] args) { 
     System.setProperty("spring.profiles.active", "dev"); 
     System.setProperty("spring.profiles.default", "dev"); 
     System.setProperty("spring.liveBeansView.mbeanDomain", "dev"); 
     ApplicationContext context = new ClassPathXmlApplicationContext("jvmmonitoring/jmxtrans/spring-beans.xml"); 
     while (true) { 

     } 
    } 
} 

루프는 JVM 통계까지 응용 프로그램을 계속 추가하는 동안 콘솔에 인쇄되어 있습니다. 무시 콩 생성 예외에 - 여기에 내가 jmxtrans 봄 콩이

디버그 osbfsDefaultListableBeanFactory 1426 때문에 봄 순환 참조 오류로 작성되지 않은 것을 발견 있도록 디버그 수준 로그 켜기 jmxtrans.json 파일

{ 
    "queries": [ 
     { 
      "objectName": "java.lang:type=Memory", 
      "resultAlias": "jvm.memory", 
      "attributes": [ 
       { 
        "name": "HeapMemoryUsage", 
        "keys": ["committed", "used"] 
       }, 
       { 
        "name": "NonHeapMemoryUsage", 
        "keys": ["committed", "used"] 
       } 
      ] 

     }, 
     { 
      "objectName": "java.lang:type=Runtime", 
      "resultAlias": "jvm.runtime", 
      "attributes": [ 
       "Uptime" 
      ] 

     }, 
     { 
      "objectName": "java.lang:type=GarbageCollector,name=*", 
      "resultAlias": "jvm.gc.%name%", 
      "attributes": [ 
       "CollectionCount", 
       "CollectionTime" 
      ] 
     }, 
     { 
      "objectName": "java.lang:type=Threading", 
      "resultAlias": "jvm.thread", 
      "attributes": [ 
       "ThreadCount" 
      ] 

     }, 
     { 
      "objectName": "java.lang:type=OperatingSystem", 
      "resultAlias": "jvm.os", 
      "attributes": [ 
       "CommittedVirtualMemorySize", 
       "FreePhysicalMemorySize", 
       "FreeSwapSpaceSize", 
       "OpenFileDescriptorCount", 
       "ProcessCpuTime", 
       "SystemLoadAverage" 
      ] 

     } 
    ], 
    "outputWriters": [ 
     { 
      "@class": "org.jmxtrans.embedded.output.ConsoleWriter" 
     } 
    ] 
} 

입니다 FactoryBean 타입 검사 : org.springframework.beans.factory.BeanCurrentlyInCreationException : 이름 'jmxtrans'로 bean 생성 오류 : 요청 된 bean이 현재 생성 중입니다. 해결할 수없는 순환 참조가 있습니까?

완전한 봄 로그

여기에 공유 - http://pastebin.com/p2VeNEzE

무엇을 누락 될 수 있을까?

감사합니다.

답변

0

순환 참조에 관한 위의 디버그 로그 메시지는 잘못된 것입니다. 이 문제는 애플리케이션 컨텍스트에서 jmxtrans 빈을 가져 와서 start() 메소드를 호출 한 후 해결되었습니다.