You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2011/05/31 15:56:47 UTC

[jira] [Resolved] (FELIX-2944) SCR/ spec version 1.1-felix is causing NPE in XmlHandler

     [ https://issues.apache.org/jira/browse/FELIX-2944?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved FELIX-2944.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: scr generator 1.1.2
                   scr-1.6.2

Fixed handling in the XmlHandler class in Rev. 1129674 and a test case in Rev. 1129677

According to the specs, elements whose namespace is not know are to be ignored. This has been done for the <component> element. But then comes the <implementation> element which is handled but there is no component context to put information into and an NPE is generated.

Now, any element is ignored if there is no component context to fill data into.

We cannot log error or warn messages since the spec states that the XML parser is to be lenient has to ignore unknown elements and namespaces. We just log DEBUG messages in these cases.

> SCR/ spec version 1.1-felix is causing NPE in XmlHandler
> --------------------------------------------------------
>
>                 Key: FELIX-2944
>                 URL: https://issues.apache.org/jira/browse/FELIX-2944
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR), Maven SCR Plugin
>    Affects Versions:  scr-1.6.0, scr generator 1.1.0
>            Reporter: Pierre De Rop
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: scr-1.6.2, scr generator 1.1.2
>
>
> This issue is described in the following post: http://www.mail-archive.com/users@felix.apache.org/msg10138.html
> and might also be related in the  FELIX-1898 issue.
> When using SCR (trunk) and the new Reference "updated" callback, we have to specify the spec version "1.1-felix". 
> However, when using such version, we get the following NPE at runtime: (latest scrplugin has been used to generate the scr xml descriptor):
> java.lang.NullPointerException
>         at org.apache.felix.scr.impl.metadata.XmlHandler.startElement(XmlHandler.java:237)
>         at org.apache.felix.scr.impl.parser.KXml2SAXParser.parseXML(KXml2SAXParser.java:73)
>         at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:227)
>         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:274)
>         at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:192)
>         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.Felix.setActiveStartLevel(Felix.java:1179)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>         at java.lang.Thread.run(Thread.java:662)
> Notice that this exception is displayed on stdout, and it would be probably better to log it using the log service;
> From log service, we then get the following exception:
> .scr.impl.parser.ParseException: Exception during parsing
>         at org.apache.felix.scr.impl.metadata.XmlHandler.startElement(XmlHandler.java:333)
>         at org.apache.felix.scr.impl.parser.KXml2SAXParser.parseXML(KXml2SAXParser.java:73)
>         at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:227)
>         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:274)
>         at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:192)
>         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.Felix.setActiveStartLevel(Felix.java:1179)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>         at java.lang.Thread.run(Thread.java:662)
> I think that the root cause of the problem is that the scrplugin is generating the following xml namespace:
>     http://www.osgi.org/xmlns/scr/v1.1.0-felix
> but the scr runtime is expecting the following namespace:
>     http://felix.apache.org/xmlns/scr/v1.1.0-felix
> so, there is a mismatch here.
> The following patch seems to work and consists in fixing the class XmlHandler.java, in the SCR: 
> The XmlHandler.NAMESPACE_URI_1_1_FELIX constant can be changed with the following scheme (which must match the one generated by the scrplugin):
>     public static final String NAMESPACE_URI_1_1_FELIX = "http://www.osgi.org/xmlns/scr/v1.1.0-felix";
> Or another option is to fix the scrplugin in order to use the felix.apache.org scheme ?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira