pax-exam and SCR

61 views
Skip to first unread message

Benson Margulies

unread,
Oct 27, 2016, 4:09:25 PM10/27/16
to OPS4J
I have a few pax-exam tests which include Apache Felix SCR 2.0.6. 

I am finding them very fragile. I make very slight changes, and SCR stops activating some critical components.

The log messages from SCR are not informative; heck, I can't even find

org.slf4j.osgi-over-slf4j[org.apache.felix.scr.2.0.6] : Starting destruction process bundle: org.yaml.snakeyaml/59

in the source code.

I don't make any special arrangements about threads. I've tried @Inject and an explicit service tracker to wait for the component; it never shows up when things are broken. Has anyone else been here? My production code that does not use pax-exam (of course) works fine.

Benson Margulies

unread,
Oct 27, 2016, 4:27:34 PM10/27/16
to op...@googlegroups.com
Debugging into ConfigurationAdmin, I see that when my code sets up the
PID that the component depends on, it reaches:

log( LogService.LOG_DEBUG, "No ConfigurationListeners to send {0}
event to.", new Object[]
{ asyncSender.getTypeName() } );
}


So SCR is somehow not listening for configuration admin events.
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - op...@googlegroups.com
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "OPS4J" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ops4j/P6vyapDiOpw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ops4j+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Christian Schneider

unread,
Oct 28, 2016, 12:24:00 AM10/28/16
to op...@googlegroups.com
Do you set up the configuration programmatically using ConfigurationAdmin ?
If yes then you might want to try the pax exam cm Module.

See this for an example:

Christian


> For more options, visit https://groups.google.com/d/optout.

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Benson Margulies

unread,
Oct 28, 2016, 6:17:33 AM10/28/16
to op...@googlegroups.com
On Fri, Oct 28, 2016 at 12:23 AM, Christian Schneider
<ch...@die-schneider.net> wrote:
> Do you set up the configuration programmatically using ConfigurationAdmin ?
> If yes then you might want to try the pax exam cm Module.

I use that.

In the debugger, I can see that SCR does not see ConfigurationAdmin.
The ConfAdminListener in SCR is never called to notice the arrival of
the CA service. Yet the CA service is there; I can obtain a reference
to it in my test.
>> > ops4j+un...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> --
>> ------------------
>> OPS4J - http://www.ops4j.org - op...@googlegroups.com
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "OPS4J" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ops4j+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - op...@googlegroups.com
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "OPS4J" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ops4j/P6vyapDiOpw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ops4j+un...@googlegroups.com.

Christoph Läubrich

unread,
Oct 28, 2016, 7:17:48 AM10/28/16
to op...@googlegroups.com
It seems a bit confusing what your real problem is but from this it
sounds like you have class-loading or dependency issue. Make sure there
is only one ConfigurationAdmin Service in your setup (e.g. activate the
console).
You might also want to adjust your Componetn config to require a
configuration. Also you should make sure that your Component behaves
right in the sense of the dynamic nature of OSGi, DS and CM...

If you describe a little more what your problem is (e.g. with a small
test-case) we can better help you. I have already used DS with
pax-exam-cm module without a problem.

Benson Margulies

unread,
Oct 30, 2016, 8:56:31 PM10/30/16
to OPS4J
If I can make a small test case I will.

Outline:

As of the prior git commit, I have a working test. It uses Pax-exam, provisioning felix config admin and scr, current versions. It uses the config admin module to set up a PID. I have a component that requires that pid. The component is activated. All works.

I made some changes that should only affect code after the call to the activate method. The tests stops working, because the component is never activated. If I debug inside of Felix SCR, I see that the SCR code that listens for ConfigurationAdmin so as to install listeners is never called. Yet CA is certainly in there; my pax-exam test can request injection of the ConfigurationAdmin service and receive it.

It is possible that I perturbed the classpath, in order or in content. That's on my list of things to recheck.

The larger integration tests of the larger system that includes these pieces all work, as well.



Christoph Läubrich

unread,
Oct 31, 2016, 2:12:43 PM10/31/16
to op...@googlegroups.com
You should then activate the debug options of Felix SCR to see whats
going on. Can you share the "working" vs the "not working" code? What
Pax-Container do you use? Remote? Embedded? Have you tried to use
immediate="true" for your component to make sure it is not delayed?

Benson Margulies

unread,
Oct 31, 2016, 2:16:50 PM10/31/16
to op...@googlegroups.com
On Mon, Oct 31, 2016 at 2:12 PM, 'Christoph Läubrich' via OPS4J
<op...@googlegroups.com> wrote:
> You should then activate the debug options of Felix SCR to see whats going
> on.

Not only have I spend hours staring at the logging output of SCR, I've
_debugged SCR_. Set breakpoints in it. Seen that, in particular, it
seems to be never notified of the arrival of the ConfigurationAdmin
service.

Can you share the "working" vs the "not working" code?

Unfortunately, no. It's part of a large, non-open-source, system.
Essentially, I'll have to debug it in place to create a test case that
I can share.


What
> Pax-Container do you use? Remote? Embedded?

The default embedded Felix container with Felix 5.4.0.

Have you tried to use
> immediate="true" for your component to make sure it is not delayed?

Yes.

>
> Am 31.10.2016 01:56, schrieb Benson Margulies:
>>
>> If I can make a small test case I will.
>>
>> Outline:
>>
>> As of the prior git commit, I have a working test. It uses Pax-exam,
>> provisioning felix config admin and scr, current versions. It uses the
>> config admin module to set up a PID. I have a component that requires that
>> pid. The component is activated. All works.
>>
>> I made some changes that should only affect code after the call to the
>> activate method. The tests stops working, because the component is never
>> activated. If I debug inside of Felix SCR, I see that the SCR code that
>> listens for ConfigurationAdmin so as to install listeners is never called.
>> Yet CA is certainly in there; my pax-exam test can request injection of the
>> ConfigurationAdmin service and receive it.
>>
>> It is possible that I perturbed the classpath, in order or in content.
>> That's on my list of things to recheck.
>>
>> The larger integration tests of the larger system that includes these
>> pieces all work, as well.
>>
>>
>

Christoph Läubrich

unread,
Oct 31, 2016, 2:28:51 PM10/31/16
to op...@googlegroups.com
Okay, then try the following:

a) use the remote container to archive maximum classloader-isolation, in larger applications you can easily pull in multiple dependencies for the same interface what can mess up with Pax-Exam
b) activate remote debugging for your container, set a breakpoint in a test method, add large timeouts to service references and activate and connect to the gogo shell and/or webconsole to have access to OSGi debugging capabilities
c) check that all relevant bundles (examp-test-probe, exam-cm-provider bundle, your ds component, felix-scr) are bound to the same org.osgi.service.cm package-import.

Even though its hard to guess without any detailed information (maybe you can share at least the output of scr info or something similar?) for me it sounds like there is more than one version of the cm-package avaiable in your current setup.

Benson Margulies

unread,
Oct 31, 2016, 2:31:46 PM10/31/16
to op...@googlegroups.com
On Mon, Oct 31, 2016 at 2:28 PM, 'Christoph Läubrich' via OPS4J
<op...@googlegroups.com> wrote:
> Okay, then try the following:
>
> a) use the remote container to archive maximum classloader-isolation, in
> larger applications you can easily pull in multiple dependencies for the
> same interface what can mess up with Pax-Exam
> b) activate remote debugging for your container, set a breakpoint in a test
> method, add large timeouts to service references and activate and connect to
> the gogo shell and/or webconsole to have access to OSGi debugging
> capabilities
> c) check that all relevant bundles (examp-test-probe, exam-cm-provider
> bundle, your ds component, felix-scr) are bound to the same
> org.osgi.service.cm package-import.
>
> Even though its hard to guess without any detailed information (maybe you
> can share at least the output of scr info or something similar?) for me it
> sounds like there is more than one version of the cm-package avaiable in
> your current setup.

Thanks. I will attempt this.

I do have scr info via code I wrote myself to dump it out. It just
shows that my component is 'unsatisfied', and debugging shows that
it's the config admin data that it's unsatisfied about. The scr info
is not informative about the number of CMs I have managed to get
tangled up with.


>
> Am 31.10.2016 19:16, schrieb Benson Margulies:
>
> On Mon, Oct 31, 2016 at 2:12 PM, 'Christoph Läubrich' via OPS4J
> <op...@googlegroups.com> wrote:
>
>
> You should then activate the debug options of Felix SCR to see whats going
> on.
>
>
> Not only have I spend hours staring at the logging output of SCR, I've
> _debugged SCR_. Set breakpoints in it. Seen that, in particular, it
> seems to be never notified of the arrival of the ConfigurationAdmin
> service.
>
> Can you share the "working" vs the "not working" code?
>
> Unfortunately, no. It's part of a large, non-open-source, system.
> Essentially, I'll have to debug it in place to create a test case that
> I can share.
>
>
> What
>
>
> Pax-Container do you use? Remote? Embedded?
>
>
> The default embedded Felix container with Felix 5.4.0.
>
> Have you tried to use
>
>
> immediate="true" for your component to make sure it is not delayed?
>
>
> Yes.
>
>
>
>

Christoph Läubrich

unread,
Nov 2, 2016, 5:01:30 AM11/2/16
to op...@googlegroups.com
Oh and just one thing that came in my mind: Make sure that the
configuration is not bound to another bundle (e.g. if you fetch it
yourself for debugging purpose) because then the SCR (or any other
bundle) won't be able to see the configuration.
Reply all
Reply to author
Forward
0 new messages