[
https://issues.apache.org/jira/browse/FELIX-2962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038756#comment-13038756
]
Andrew Pimlott commented on FELIX-2962:
---------------------------------------
You're right, I should give a real-world example. The one that tripped me is
copy-n-pasted from page 145 of the OSGi 4.2 Enterprise Specification:
<xml version="1.0" encoding="UTF-8">
<scr:component name="example.handler"
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="com.acme.HandlerImpl"/>
<property name="event.topics">some/topic</property>
<service>
<provide interface=
"org.osgi.service.event.EventHandler"/>
</service>
<scr:component>
Note the typo where the final tag is an open tag instead of a close. (I
reported this to OSGi: https://www.osgi.org/bugzilla/show_bug.cgi?id=120.)
When I started the service, I got this error:
ERROR: org.example.bundle (3): [null] Cannot register Component
org.osgi.service.component.ComponentException: Component null validation
failed: Implementation class name missing
at
org.apache.felix.scr.impl.metadata.ComponentMetadata.validationFailure(ComponentMetadata.java:777)
at
org.apache.felix.scr.impl.metadata.ComponentMetadata.validate(ComponentMetadata.java:645)
at
org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:241)
at
org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:147)
at
org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:111)
at
org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:285)
at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:203)
at
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)
at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3833)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1803)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:927)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:914)
at Try.main(Try.java:78)
Actually, my component was successfully registered. The error is about the
empty component started by the second <scr:component> tag. But due to this
message, I went crazy trying to figure out what was wrong with my
<implementation> tag.
> SCR doesn't detect invalid XML
> ------------------------------
>
> Key: FELIX-2962
> URL: https://issues.apache.org/jira/browse/FELIX-2962
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Reporter: Andrew Pimlott
> Labels: xml
>
> The XML parser (kxml2) used by SCR doesn't detect many forms of incorrect
> XML, even basic errors like mismatched start and end tags. This makes
> diagnosing component load errors very frustrating. Please use a real XML
> parser. It will save developers a lot of pain.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira