It all depends of the mode you rune your tests (mebedded or forked) pax-exma is pulling nothing "in" or exposing anything to OSGi if you do not ask for it.

You should also distinguisch between maven-depndencies declared in your pom and maven-urls declared in feature files.

The first are never used or required by pax-exam you can add abritary maven-urls to your test without even having them in any transitive pom. The only feature that require this is the "versionAsInPom()" but for that the scope dosent matter! Thats why "test" scope dosen't change anything.

The Problem you are sseing is a classic "jar-hell"-problem of code that relies on a linear classpath that makes everything accessible.

What happens is that maven(!) builds up a large classpath containig your dedendencies+transitive ones and offers this to the application running the test that is JUnit+Pax Exam. Pax Exam now starts a Karaf-Container and something inside the container requests some kind of XML-Parser and Java(!) return the first it founds that might be not the one you wanted/needed.

So if this component would have used some OSGi way to obtain an XML-Parser of required version and implementation specification there won't be any problem at all.

So there are two ways to resolve this (none of wich are realted to feature file itself):
 - generate your feature in a seperate module
 - run karaf in forked mode

The reason is, that the feature file itself has nothing to do with your pom or exam test, you can try this yourself by creating a feature that has a missing requirement, adding this requirement to your pom won't cachnge the situation (if its an OSGi requirement), it won't install.


Am 15.10.2017 um 09:34 schrieb Steinar Bang:
Steinar Bang <s...@dod.no>:



So I'm guessing what happens is that pax exam pulls in all compile scope
and test scope dependencies(*) and offer them up as exported osgi
packages to the pax exam test's OSGi runtime.  And if the packages are
in conflict with something else (in this case the karaf boot), there are
problems.

My original question was: Is it possible to create a karaf feature file
for use in a pax exam test, by adding compile scope dependencies to the
pax exam maven project and use karaf-maven-plugin to generate the
feature file?

The answer to my original question, is: Yes, but only for such top level
dependencies that won't conflict with other OSGi components running in
the pax exam OSGi runtime.  Beware of transitive dependencies of the
packages you're creating feature files for.


(*) I tried test scope as well, got the same boot error there



--
--
------------------
OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to