2016-09-14 80 views
1

我正在研究跟蹤代理,並嘗試添加新協議以用於我的設備。我試圖模仿你與GL200協議做了什麼,但是當它達到TrackerFactory.create(),它返回以下錯誤:Cumulocity實施新協議

16:05:47.912 [pool-2-thread-1] ERROR c8y.trackeragent.RequestHandler - Error handling request: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectedAXTracker': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected java.util.List c8y.trackeragent.ConnectedTracker.fragments; nested exception is org.springframework.beans.factory.NoSuchBeanDefinition 
Exception: No qualifying bean of type [c8y.trackeragent.Fragment] found for dependency [collection of c8y.trackeragent.Fragment]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:217) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:350) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at c8y.trackeragent.protocol.mapping.TrackerFactory.create(TrackerFactory.java:76) ~[classes/:na] 
     at c8y.trackeragent.protocol.mapping.TrackerFactory.discoverTracker(TrackerFactory.java:48) ~[classes/:na] 
     at c8y.trackeragent.protocol.mapping.TrackerFactory.getTracker(TrackerFactory.java:33) ~[classes/:na] 
     at c8y.trackeragent.RequestHandler.run(RequestHandler.java:32) ~[classes/:na] 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_91] 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_91] 
     at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91] 
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected java.util.List c8y.trackeragent.ConnectedTracker.fragments; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [c8y.trackeragent.Fragment] found for dependency [collection of c8y.trackeragent.Fragment]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     ... 14 common frames omitted 
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [c8y.trackeragent.Fragment] found for dependency [collection of c8y.trackeragent.Fragment]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1308) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 

     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1006) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE] 
     ... 16 common frames omitted 

我沒有春天的知識,你能不能給我一個提示?

+0

例如,GL200Fragment在何處/如何聲明爲Bean? –

回答

1

我發現問題:我擴展AXFragment接口(本身擴展Fragment)的類沒有標記爲@Component。

0

從堆棧跟蹤發生這種情況: 它發現跟蹤器連接是您添加的類型,但是當嘗試實例化類時失敗了,因爲它無法設置該類所需的fragements列表。

每個跟蹤器協議都需要至少一個片段(一個實現c8y.trackeragent.Fragment的類)。

如果你看看GL200的實現,還有另外一個接口GL200Fragment,然後例如解析器(GL200Parser)實現了這個接口。它看起來像你沒有添加任何實現此接口的類。

+0

你好,thx爲答案。但我做到了!我的課ConnectedAXTracker擴展了ConnectedTracker ,AXFragment擴展了片段和抽象類AXParser實現了Parser,AXFragment。還有什麼我錯過了嗎? –