简体   繁体   English

Cumulocity 实施新协议

[英]Cumulocity implementing new protocol

I'm working on the tracker-agent and trying to add a new protocol to use with my devices.我正在研究跟踪器代理并尝试添加一个新协议以与我的设备一起使用。 I tried to mimic what you did with the GL200 protocol, however when it reaches TrackerFactory.create(), it returns the following error:我试图模仿你对 GL200 协议所做的事情,但是当它到达 TrackerFactory.create() 时,它返回以下错误:

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

I have no knowledge of Spring, could you give me a hint?我对 Spring 一无所知,你能给我一个提示吗?

我发现了问题:我扩展 AXFragment 接口(本身扩展 Fragment)的类没有被标记为 @Component。

Just from the stack trace this happened: It discovered that the tracker connecting was of the type you added but when trying to instantiate the class it failed because it could not set the fragements list that is required for that class.仅从堆栈跟踪中就发生了这种情况:它发现连接的跟踪器属于您添加的类型,但是在尝试实例化类时失败,因为它无法设置该类所需的片段列表。

Every tracker protocol needs to have at least on fragment (a class implementing c8y.trackeragent.Fragment).每个跟踪器协议至少需要有一个片段(一个实现 c8y.trackeragent.Fragment 的类)。

If you look at the GL200 implementation there is another interface GL200Fragment and then for example the parser (GL200Parser) implements that interface.如果您查看 GL200 实现,则有另一个接口 GL200Fragment,然后例如解析器 (GL200Parser) 实现该接口。 It looks like you did not add any class that implements this interface.看起来您没有添加任何实现此接口的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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