Hello everyone,

I have a SCR component which defines the following xml configuration:

<?xml version='1.0' encoding='utf-8'?>
<component name='EnglishDictionary' xmlns='http://www.osgi.org/xmlns/scr/v1.1.0' factory='true' configuration-policy='require' modified='updated'> <implementation class='com.alcatel_lucent.samples.scr.dictionary.english.EnglishDictionary'/>
 <service>
<provide interface='com.alcatel_lucent.samples.scr.dictionary.DictionaryService'/>
 </service>
</component>

-> as you can see, the component "EnglishDictionary" has the factory flag, telling that another factory component will activate it. -> and the configuration policy is "require", meaning that the component must not be activated if the corresponding Configuration object is not yet available

----------------------------------------------------------------------------------

Now, here is my factory component:

<?xml version='1.0' encoding='utf-8'?>
<component name='EnglishDictionaryFactory'>
<implementation class='com.alcatel_lucent.samples.scr.dictionary.english.EnglishDictionaryFactory'/> <reference name='bind' interface='org.osgi.service.component.ComponentFactory' bind='bind' unbind='unbind' target='(component.name=EnglishDictionary)'/>
</component>

-> so, this factory component will track the "ComponentFactory" object with the target "component.name" == "EnglishDictionary".
Here is the corresponding bind method:

class EnglishDictionaryFactory {
 public void bind(ComponentFactory factory) {
   factory.newInstance(new Hashtable());
 }
}

-> The issue is that, when the factory.newInstance() method is invoked, I then get the following exception:

2009-12-06 18:00:50,226 SCR Component Actor ERROR osgi config/ca - [EnglishDictionaryFactory] The bind method has thrown an exception

org.osgi.service.component.ComponentException: Failed activating component
at org.apache.felix.scr.impl.manager.ComponentFactoryImpl.newInstance(ComponentFactoryImpl.java:118) at com.alcatel_lucent.samples.scr.dictionary.english.EnglishDictionaryFactory.bind(EnglishDictionaryFactory.java:19)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:213) at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38) at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:542) at org.apache.felix.scr.impl.helper.BaseMethod$NotResolved.invoke(BaseMethod.java:500) at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:434) at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:997) at org.apache.felix.scr.impl.manager.DependencyManager.bind(DependencyManager.java:908) at org.apache.felix.scr.impl.manager.DependencyManager.open(DependencyManager.java:832) at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:200) at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:118) at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:982) at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:297) at org.apache.felix.scr.impl.manager.AbstractComponentManager$1.doRun(AbstractComponentManager.java:137) at org.apache.felix.scr.impl.ComponentActivatorTask.run(ComponentActivatorTask.java:67) at org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:96)
       at java.lang.Thread.run(Thread.java:619)



Now, If I remove the configuration-policy='require' parameter from the EnglishDictionary component, then I don't have the exception anymore. So, am I doing something very bad or is it a bug regarding factory components and "require" configuration policy ?

thanks for your help;
/pierre

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to