OSGI DS:属性 - > ParseException的

时间:2015-07-10 14:01:48

标签: java osgi apache-felix

我使用apache felix,我的DS有以下注释

@Component(immediate = false,properties = {"name:String=stub"})

Maven生成以下xml

<component ...>
<implementation ..../>
<service>
....
</service>
<properties enty="name:String=stub"/>
</component>

然而,当我开始这个包时,我得到以下内容:

ERROR: com.temp.biz (55): General problem with descriptor entry '/OSGI-INF/com.temp.MyClass.xml'
org.apache.felix.scr.impl.parser.ParseException: Exception during parsing
    at org.apache.felix.scr.impl.metadata.XmlHandler.startElement(XmlHandler.java:364)
    at org.apache.felix.scr.impl.parser.KXml2SAXParser.parseXML(KXml2SAXParser.java:82)
    at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:245)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:158)
    at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:120)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:258)
    at org.apache.felix.scr.impl.Activator.access$000(Activator.java:45)
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:185)
    at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
    at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:479)
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:414)
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
    at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:443)
    at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:913)

如何解决?当我从@Component中移除属性时,问题就会消失。

1 个答案:

答案 0 :(得分:2)

对于OSGi DS @Component annotation,您要使用property

@Component(immediate = false, property = {"name:String=stub"})

有关Felix SCR注释,请参阅the documentation