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 14:52:47 UTC

[jira] [Updated] (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 updated FELIX-2944:
-------------------------------------

          Component/s: Maven SCR Plugin
    Affects Version/s: maven-scr-plugin-1.7.0
                        scr-1.6.0
             Assignee: Felix Meschberger

Thanks, Pierre, for tracking this down.

Actually, I think the problem is the SCR Plugin not setting the correct URI -- I don't think the Apache Felix project should define namespaces in the osgi.org domain. So the fix is to change the SCR Plugin to use the correct Namespace URI.

In fact, there is another issue: The XML parser should not print to stdout (already fixed in Rev. 1129137 for FELIX-2962) and should print something readable and not just throw a NPE.

> 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: maven-scr-plugin-1.7.0,  scr-1.6.0
>            Reporter: Pierre De Rop
>            Assignee: Felix Meschberger
>            Priority: Minor
>
> 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