Re: ComponentException: Field value type must not be set for unary field references.

2016-01-24 Thread Karel Haeck
or you can specify the field as final and initialize it with a thread safe list. There are actually three ways to handle changes in the list of FileReaderService services 1) let SCR modify the list @Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy=ReferencePolicy.DYNAMIC)

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-22 Thread Raymond Auge
Perhaps you should enable this reference to be dynamic. In your current configuration it's static which means that resolution of services happens at the moment the component is instantiated and never beyond that, even if later services might satisfy it as well. You probably want something that is

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-22 Thread David Jencks
multiple-dynamic-reluctant and multiple-dynamic-greedy have exactly the same behavior, you could specify either one, i.e. you can leave out the policyOption. Just to make things more complicated, if you are configuring your component with config admin and know exactly how many services will

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-22 Thread David Jencks
um, multiple and dynamic is greedy anyway, so you don’t need to specify it explicitly. multiple and static requires specifying greedy explicitly to get the greedy behavior. Other than that, I think your explanation is correct. david jencks > On Jan 22, 2016, at 7:20 AM, Raymond Auge

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-22 Thread ben
One last thing, the field has to be declared volatile. Otherwise, you get the following error: Field availableServices in component class org.test.FileReaderFactory must be declared volatile to handle a dynamic reference In the end, here is what I use: @Reference(cardinality =

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-22 Thread ben
Hi everyone, I'm back with my issue for an erratum: the solution I provided does not completely work. When I use: @Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE) private List availableServices; Only one of the file reader services is inserted in the list. Output of the code is:

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-22 Thread ben
In fact, its worst than that. Both ReferenceCardinality.MULTIPLE and ReferenceCardinality.AT_LEAST_ONE seem to be randomly failing. There seems to be some kind of concurrent problem when both services start at the same time: sometimes both are added to the service list, sometimes only one.

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-14 Thread ben
Hi David, By looking in Felix SCR source code I found the lines causing the exception: // field value type if ( !m_isMultiple ) { // value type must not be specified for unary references if ( m_field_collection_type != null ) { throw componentMetadata.validationFailure(

ComponentException: Field value type must not be set for unary field references.

2016-01-12 Thread ben
Hi everyone, I have a ComponentException in Felix SCR that I don't understand. Here is my use case: 1) I have a file reader service that reads a file: public interface FileReaderService { /** * Reads the given file. * @param filePath Path of the file to read * @return the

Re: ComponentException: Field value type must not be set for unary field references.

2016-01-12 Thread David Jencks
Yes, this is a better place to ask :-) I don’t see what’s wrong by just looking, I’m hoping to have enough time shortly to try your code, unless someone else gets there first. thanks david jencks > On Jan 12, 2016, at 11:02 PM, b...@petinou.fr wrote: > > Hi everyone, > > I have a