felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Jencks (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (FELIX-2925) java.lang.NullPointerException: reference and pid must not be null
Date Sun, 31 Mar 2013 06:09:15 GMT

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

David Jencks closed FELIX-2925.
-------------------------------

    Resolution: Invalid

This is a config admin bug.
                
> java.lang.NullPointerException: reference and pid must not be null
> ------------------------------------------------------------------
>
>                 Key: FELIX-2925
>                 URL: https://issues.apache.org/jira/browse/FELIX-2925
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> #################
> getting this:
> *ERROR* Unexpected problem executing task
> java.lang.NullPointerException: reference and pid must not be null
> 	at org.osgi.service.cm.ConfigurationEvent.<init>(ConfigurationEvent.java:120)
> 	at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:1818)
> 	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:104)
> 	at java.lang.Thread.run(Thread.java:662)
> #################
> at this line:
> 			conf.update(props);
> #################
> for this snippet:
> package com.barchart.mgr;
> import java.util.Date;
> import java.util.Dictionary;
> import java.util.Properties;
> import org.apache.felix.scr.annotations.Activate;
> import org.apache.felix.scr.annotations.Component;
> import org.apache.felix.scr.annotations.Deactivate;
> import org.apache.felix.scr.annotations.Reference;
> import org.osgi.service.cm.Configuration;
> import org.osgi.service.cm.ConfigurationAdmin;
> import org.osgi.service.component.ComponentContext;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> @Component
> public class HelloManager {
> 	private static Logger log = LoggerFactory.getLogger(HelloManager.class);
> 	@Reference
> 	private ConfigurationAdmin admin;
> 	@Activate
> 	protected synchronized void activate(ComponentContext context) {
> 		log.debug("ACTIVATE");
> 		log.debug("admin: {}", admin);
> 		try {
> 			Configuration[] confArray = admin.listConfigurations(null);
> 			if (confArray == null) {
> 				log.debug("confArray == null");
> 			} else {
> 				for (Configuration conf : confArray) {
> 					log.debug("conf: {}", conf);
> 				}
> 			}
> 			String pid = "com.barchart.hello.impl.CompSingle";
> 			Configuration conf = admin.getConfiguration(pid, null);
> 			conf.update();
> 			log.debug("conf: {}", conf);
> 			Dictionary props = conf.getProperties();
> 			if (props == null) {
> 				log.debug("props == null");
> 				props = new Properties();
> 				props.put("created", new Date().toString());
> 			}
> 			conf.update(props);
> 		} catch (Exception e) {
> 			log.error("", e);
> 		}
> 	}
> 	@Deactivate
> 	protected synchronized void deactivate(ComponentContext context) {
> 		log.debug("DEACTIVATE");
> 	}
> }
> #################

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message