You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2017/04/14 16:21:23 UTC

Is there a recent pax exam karaf provisioning example somewhere?

Since I have been using karaf for the last 6 months or so, it would be a
good idea to convert the pax exam tests
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java
to karaf provisioning (so that I can use the features and not have to
figure out individual bundles on my own).

A quick google search found me
 http://stackoverflow.com/a/19896241
which points to
 https://github.com/ANierbeck/Camel-Pax-Exam-Demo/blob/master/route-control/src/test/java/de/nierbeck/camel/exam/demo/control/route/KarafRoutingTest.java

But the KarafRoutingTest.java gives me two questions:
 1. The setup seems kind of cumbersome? Is it necessary to specify all
    of that? Is it necessary to specify the karafVersion()? I would have
    thought it was implicit from the version of the zip artifact?
 2. The example uses karaf version 3.0.0 and last checkin on the file
    was in January 2014, so it is fairly old? Is there a more recent
    example somewhere?

(It's possible that google can find me something eventually, but since
something as old as the above was the first search hit, I'm thinking
there may not be any...? Or that I'm searching for the wrong thing? My
search text was "pax exam use karaf features")


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Steinar,

it depends on what you want to test.

ignoreLocalConsole can safely be enabled, it will produce much less noise
on your log for your unit test.

for a full list of configuration options, take a look at the Pax Exam
documentation [1].


regards, Achim

[1] - https://ops4j1.jira.com/wiki/display/PAXEXAM4/Pax+Exam

2017-04-14 18:44 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> Zoran Regvart <zo...@regvart.com>:
>
> > I've done a couple of tests in this repository, perhaps that would be
> > of use to you:
>
> > https://github.com/zregvart/fuse-credential-store/tree/
> master/fuse-credential-store-karaf-parent/fuse-credential-
> store-karaf-itests
>
> Thanks! Looking at them now. :-)
>
> What's the ignoreLocalConsole() option? Switching off output to the
> local console? (I don't think I want that)
>
> (I assume the ignoreRemoteShell() option switches off the ssh server,
> and that's OK)
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Zoran Regvart <zo...@regvart.com>:

> I've done a couple of tests in this repository, perhaps that would be
> of use to you:

> https://github.com/zregvart/fuse-credential-store/tree/master/fuse-credential-store-karaf-parent/fuse-credential-store-karaf-itests

Thanks! Looking at them now. :-)

What's the ignoreLocalConsole() option? Switching off output to the
local console? (I don't think I want that)

(I assume the ignoreRemoteShell() option switches off the ssh server,
and that's OK)


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Zoran Regvart <zo...@regvart.com>.
Hi Steinar,
I've done a couple of tests in this repository, perhaps that would be
of use to you:

https://github.com/zregvart/fuse-credential-store/tree/master/fuse-credential-store-karaf-parent/fuse-credential-store-karaf-itests

zoran

On Fri, Apr 14, 2017 at 6:30 PM, Steinar Bang <sb...@dod.no> wrote:
>>>>>> Steinar Bang <sb...@dod.no>:
>
>> But the KarafRoutingTest.java gives me two questions:
>>  1. The setup seems kind of cumbersome? Is it necessary to specify all
>>     of that? Is it necessary to specify the karafVersion()? I would have
>>     thought it was implicit from the version of the zip artifact?
>>  2. The example uses karaf version 3.0.0 and last checkin on the file
>>     was in January 2014, so it is fairly old? Is there a more recent
>>     example somewhere?
>
> This one
>  http://stackoverflow.com/a/33933342
> pointing to
>  https://github.com/ANierbeck/Karaf-Cassandra/blob/master/Karaf-Cassandra-ITest/src/test/java/de/nierbeck/cassandra/itest/TestBase.java
> looks more promising.
>
> The setup was way smaller, and the last checkin was just a year ago.
>
> (but if there is something easier yet, for karaf 4.0.9 and/or 4.1.1,
> please let me know!)
>



-- 
Zoran Regvart

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> But the KarafRoutingTest.java gives me two questions:
>  1. The setup seems kind of cumbersome? Is it necessary to specify all
>     of that? Is it necessary to specify the karafVersion()? I would have
>     thought it was implicit from the version of the zip artifact?
>  2. The example uses karaf version 3.0.0 and last checkin on the file
>     was in January 2014, so it is fairly old? Is there a more recent
>     example somewhere?

This one
 http://stackoverflow.com/a/33933342
pointing to
 https://github.com/ANierbeck/Karaf-Cassandra/blob/master/Karaf-Cassandra-ITest/src/test/java/de/nierbeck/cassandra/itest/TestBase.java
looks more promising.

The setup was way smaller, and the last checkin was just a year ago.

(but if there is something easier yet, for karaf 4.0.9 and/or 4.1.1,
please let me know!)


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:

> And it might be that this is an issue on your windows box, cause I
> rarely have this kind of behavior on a mac.

Right. My production system is debian GNU/linux, and I also have a
debian dev box, so I could try there if I'm completely stumped.

On the other hand I prefer to have a build that behaves identically on
different platforms... so I think I will continue trying until it works.


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Achim Nierbeck <bc...@googlemail.com>.
And it might be that this is an issue on your windows box, cause I rarely
have this kind of behavior on a mac.

regards, Achim

2017-04-15 15:55 GMT+02:00 Achim Nierbeck <bc...@googlemail.com>:

> Hi,
>
> the karaf container is always a forked process. If you want to run it as
> non-forked you can use the following configuration:
>
> runEmbedded(true)
>
> this is especially useful if you want to debug your tests, but beware
> because of the nature of how the tests run, this can only be used with
> debugging and one test-method.
>
> regards, Achim
>
>
> 2017-04-15 14:57 GMT+02:00 Steinar Bang <sb...@dod.no>:
>
>> >>>>> Steinar Bang <sb...@dod.no>:
>>
>> > There is this output at the end of the "mvn clean install":
>> > [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test
>> (default-test) on project ukelonn.tests: Execution default-test of goal
>> org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The
>> forked VM terminated without properly saying goodbye. VM crash or
>> System.exit called?
>> > [ERROR] Command was cmd.exe /X /C ""C:\Program
>> Files\Java\jdk1.8.0_121\jre\bin\java" -jar C:\Users\sbang\workspaces\ws06
>> \ukelonn\ukelonn.tests\target\surefire\surefirebooter5197692333401719291.jar
>> C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\
>> surefire\surefire8860295739440543272tmp C:\Users\sbang\workspaces\ws06
>> \ukelonn\ukelonn.tests\target\surefire\surefire_05835872688929628334tmp"
>>
>> > Obviously maven thinks the process has terminated.  Just as obviously
>> > there is still a java process running (that prevents delete of the
>> > target\exam directory structure).
>>
>> The documentation says "With the Forked Container, the system under test
>> runs in a separate Java virtual machine under remote control from the
>> test driver."
>>  https://ops4j1.jira.com/wiki/display/PAXEXAM4/Pax+Exam
>>
>> How do I figure out whether I'm running a "forked container" or not?
>>
>> Is the mentioned "forked VM" in the rror message that has terminated,
>> the VM actually running the tests? (ie. the single VM started in a
>> "non-forked container" (or whatever it is called)...?).
>>
>> Or is the "forked VM" of the error message the front end that forks yet
>> another VM to do the job, and it's this second VM that is left running?
>> (ie. the "forked VM" of the error message is a VM started by maven
>> surefire, and this VM runs a "forked container" that starts yet another
>> VM where karaf is started and tests are run)
>>
>>
>
>
> --
>
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
> Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>
> Software Architect / Project Manager / Scrum Master
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:
> 2017-04-15 19:39 GMT+02:00 Steinar Bang <sb...@dod.no>:

[snip!}
>> Now I'm back to the issue of why the pax-jdbc feature isn't found:
>> 1. It's found in a regular karaf instance
>> 2. It didn't help specifying the feature repository containing the
>>    feature pax-jdbc in my feature file

> Did you also reference the pax-jdbc feature in your feature file?

Yes I did.

More specifically: I've referenced the pax-jdbc feature from by my derby
database feature, for as long as I've been using karaf features...:-)
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.bundle.test.db/src/main/feature/feature.xml#L4

What did eventually make the pax exam test with the karaf container work
for me, was to load the pax-jdbc feature repository in the configuration
of the karaf container for the pax exam test:
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java#L48

As I've said in a different message in this thread, I don't need to
specifically load the pax-jdbc feature repository when using a regular
karaf 4.0.7 or 4.0.9 container.  In that case it is enough to just
reference the feature.

> You'll need to declare that dependency to be installed.

I know. :-)


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Did you also reference the pax-jdbc feature in your feature file?
You'll need to declare that dependency to be installed.

regards, Achim


2017-04-15 19:39 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> You wrote:
>
> > For now, I will go back to the surefire config (it saves me the job of
> > manually killing the leftover java processes, and gets further before
> > it fails).
>
> Summary: The surefire "<forkCount>0</forkCount>" config didn't work, and
> the leftover Java VM is a problem with surefire 2.19 and later
>
> With the surefire "<forkCount>0</forkCount>" config in place, the test
> failed much earlier, before the karaf runtime was even ready to start:
>  [WARNING] useSystemClassloader setting has no effect when not forking
>  Running no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
>  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
>  SLF4J: Defaulting to no-operation (NOP) logger implementation
>  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for
> further details.
>  Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.132 sec
> <<< FAILURE! - in no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
>  no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed:
> 0.123 sec  <<< ERROR!
>  java.lang.RuntimeException: Problem starting container
>  Caused by: java.net.MalformedURLException: unknown protocol: mvn
>
>  no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed:
> 0.132 sec  <<< ERROR!
>  java.lang.NullPointerException
>          at org.apache.maven.surefire.junit4.JUnit4Provider.execute(
> JUnit4Provider.java:367)
>          at org.apache.maven.surefire.junit4.JUnit4Provider.
> executeWithRerun(JUnit4Provider.java:274)
>          at org.apache.maven.surefire.junit4.JUnit4Provider.
> executeTestSet(JUnit4Provider.java:238)
>          at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(
> JUnit4Provider.java:161)
>
> The leftover Java VM is a surefire issue.  It is an issue both with
> surefire 2.19.1 that I was running, and the current surefire 2.20.
>  http://maven.40175.n5.nabble.com/surefire-forked-vm-failed-
> tp5858900p5859320.html
>
> However, leftover VM isn't an issue with surefire 2.18, so I've
> downgraded to surefire 2.18.
>
> Now I'm back to the issue of why the pax-jdbc feature isn't found:
>  1. It's found in a regular karaf instance
>  2. It didn't help specifying the feature repository containing the
>     feature pax-jdbc in my feature file
>
> All and any ideas are welcome!
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> You wrote:

> For now, I will go back to the surefire config (it saves me the job of
> manually killing the leftover java processes, and gets further before
> it fails).

Summary: The surefire "<forkCount>0</forkCount>" config didn't work, and the leftover Java VM is a problem with surefire 2.19 and later

With the surefire "<forkCount>0</forkCount>" config in place, the test
failed much earlier, before the karaf runtime was even ready to start:
 [WARNING] useSystemClassloader setting has no effect when not forking
 Running no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
 SLF4J: Defaulting to no-operation (NOP) logger implementation
 SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
 Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.132 sec <<< FAILURE! - in no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
 no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed: 0.123 sec  <<< ERROR!
 java.lang.RuntimeException: Problem starting container
 Caused by: java.net.MalformedURLException: unknown protocol: mvn

 no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed: 0.132 sec  <<< ERROR!
 java.lang.NullPointerException
         at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
         at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
         at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
         at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)

The leftover Java VM is a surefire issue.  It is an issue both with
surefire 2.19.1 that I was running, and the current surefire 2.20.
 http://maven.40175.n5.nabble.com/surefire-forked-vm-failed-tp5858900p5859320.html

However, leftover VM isn't an issue with surefire 2.18, so I've
downgraded to surefire 2.18.

Now I'm back to the issue of why the pax-jdbc feature isn't found:
 1. It's found in a regular karaf instance
 2. It didn't help specifying the feature repository containing the
    feature pax-jdbc in my feature file

All and any ideas are welcome!


Re: "No Karaf main found" when using runEmbedded(true) on pax exam test

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofr <jb...@nanthrax.net>:

> I will update the doc/latest release.

Ok. Good! :-)

And I can verify that upgrading pax exam from 4.9.1 to 4.10.0 worked for
me, and that I am now successfully running the pax exam karaf container
in embedded mode on windows.

My version numbers are:
 pax exam version 4.10.0
 karaf version 4.0.9

(The reason for running in embedded mode was to make it possible to debug
the tests.)





Re: "No Karaf main found" when using runEmbedded(true) on pax exam test

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

I will update the doc/latest release.

Regards
JB

On 04/17/2017 09:03 AM, Steinar Bang wrote:
>>>>>> Steinar Bang <sb...@dod.no>:
>
>>> I googled the error message and found this pax exam issue:
>>> https://ops4j1.jira.com/browse/PAXEXAM-742
>
>>> PAXEXAM-742 is fixed in pax exam 4.7.0.
>
>>> I am currently running pax exam 4.9.1 and karaf 4.0.9 (got the same
>>> error on karaf 4.0.7).
>
>>> Could it be that the error has reappeared in pax exam?
>
>>> Or am doing something wrong in the setup or have something missing from
>>> the setup?
>
>> I know why: it's because I'm on windows.
>
>> It's this test in KarafEmbeddedRunner:
>>                     else {
>>                         if (file.getPath().contains("/boot")) {
>>                             // karaf 4.x
>>                             mainBundles.add(file);
>>                         }
>
>> My file here is has "\boot", rather than "/boot":
>> C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\exam\6086a15a-1ba8-45c4-856d-28e0e7693337\lib\boot\org.apache.karaf.diagnostic.boot-4.0.9.jar
>
>> I will try to make a fix and create a pull request.
>
> No need.  This is already fixed in git:
>  https://github.com/ops4j/org.ops4j.pax.exam2/commit/470aa720f314ddbd4cff4bfe39fee835b1cba598
>
> The pax exam documentation mentions 4.9.1 as the newest
>  https://ops4j1.jira.com/wiki/display/PAXEXAM4/Pax+Exam
>
> But it looks like 4.10 has been released to maven central, and it looks
> like 4.10 might contain the fix.  I will try that.
>

-- 
Jean-Baptiste Onofr
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: "No Karaf main found" when using runEmbedded(true) on pax exam test

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>> I googled the error message and found this pax exam issue:
>> https://ops4j1.jira.com/browse/PAXEXAM-742

>> PAXEXAM-742 is fixed in pax exam 4.7.0.

>> I am currently running pax exam 4.9.1 and karaf 4.0.9 (got the same
>> error on karaf 4.0.7).

>> Could it be that the error has reappeared in pax exam?

>> Or am doing something wrong in the setup or have something missing from
>> the setup?

> I know why: it's because I'm on windows.

> It's this test in KarafEmbeddedRunner:
>                     else {
>                         if (file.getPath().contains("/boot")) {
>                             // karaf 4.x
>                             mainBundles.add(file);
>                         } 

> My file here is has "\boot", rather than "/boot":
> C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\exam\6086a15a-1ba8-45c4-856d-28e0e7693337\lib\boot\org.apache.karaf.diagnostic.boot-4.0.9.jar

> I will try to make a fix and create a pull request.

No need.  This is already fixed in git:
 https://github.com/ops4j/org.ops4j.pax.exam2/commit/470aa720f314ddbd4cff4bfe39fee835b1cba598

The pax exam documentation mentions 4.9.1 as the newest
 https://ops4j1.jira.com/wiki/display/PAXEXAM4/Pax+Exam

But it looks like 4.10 has been released to maven central, and it looks
like 4.10 might contain the fix.  I will try that.


Re: "No Karaf main found" when using runEmbedded(true) on pax exam test

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
> I googled the error message and found this pax exam issue:
>  https://ops4j1.jira.com/browse/PAXEXAM-742

> PAXEXAM-742 is fixed in pax exam 4.7.0.

> I am currently running pax exam 4.9.1 and karaf 4.0.9 (got the same
> error on karaf 4.0.7).

> Could it be that the error has reappeared in pax exam?

> Or am doing something wrong in the setup or have something missing from
> the setup?

I know why: it's because I'm on windows.

It's this test in KarafEmbeddedRunner:
                    else {
                        if (file.getPath().contains("/boot")) {
                            // karaf 4.x
                            mainBundles.add(file);
                        } 

My file here is has "\boot", rather than "/boot":
C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\exam\6086a15a-1ba8-45c4-856d-28e0e7693337\lib\boot\org.apache.karaf.diagnostic.boot-4.0.9.jar

I will try to make a fix and create a pull request.

Should I create a Jira issue first?  Eg. "Pax exam karaf with embedded
karaf doesn't work on windows"?

Is the self registration up and running in Jira?


"No Karaf main found" when using runEmbedded(true) on pax exam test (Was: Is there a recent pax exam karaf provisioning example somewhere?)

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>  Running no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
>  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
>  SLF4J: Defaulting to no-operation (NOP) logger implementation
>  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
>  Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException: No Karaf main found
                                                                         ^^^^^^^^^^^^^^^^^^^
>          at org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:85)
>  Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 182.318 sec <<< FAILURE! - in no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
>  no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed: 182.015 sec  <<< ERROR!
>  java.lang.RuntimeException: Cannot get the remote bundle context
>  Caused by: java.rmi.NotBoundException: bfa21964-9d13-4a55-b633-f0bc4368077a

Since I would like to be able to debug into the pax exam test, I tried
running the karaf container embedded again.

But I still got the "No karaf main found" error message.

I googled the error message and found this pax exam issue:
 https://ops4j1.jira.com/browse/PAXEXAM-742

PAXEXAM-742 is fixed in pax exam 4.7.0.

I am currently running pax exam 4.9.1 and karaf 4.0.9 (got the same
error on karaf 4.0.7).

Could it be that the error has reappeared in pax exam?

Or am doing something wrong in the setup or have something missing from
the setup?

Here's the config:
    @Configuration
    public Option[] config() {
        final MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf-minimal").type("zip").versionAsInProject();
        final MavenArtifactUrlReference paxJdbcRepo = maven().groupId("org.ops4j.pax.jdbc").artifactId("pax-jdbc-features").versionAsInProject().type("xml").classifier("features");
        final MavenArtifactUrlReference ukelonnFeatureRepo = maven().groupId("no.priv.bang.ukelonn").artifactId("ukelonn.karaf").versionAsInProject().type("xml").classifier("features");
        return options(
            karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new File("target/exam")).useDeployFolder(false).runEmbedded(true),
            configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
            junitBundles(),
            features(paxJdbcRepo),
            features(ukelonnFeatureRepo, "ukelonn-db-derby-test", "ukelonn"));
    }


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:

> totally different ;)

Right.  The behaviour was different as well:
With
    public Option[] config() {
        final MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf-minimal").type("zip").versionAsInProject();
        final MavenArtifactUrlReference karafStandrdRepo = maven().groupId("org.apache.karaf.features").artifactId("standard").versionAsInProject().type("xml").classifier("features");
        final MavenArtifactUrlReference ukelonnFeatureRepo = maven().groupId("no.priv.bang.ukelonn").artifactId("ukelonn.karaf").versionAsInProject().type("xml").classifier("features");
        return options(
            karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new File("target/exam")).useDeployFolder(false).runEmbedded(true),
            configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
            features(karafStandrdRepo, "pax-jdbc"),
            junitBundles(),
            features(ukelonnFeatureRepo, "ukelonn-db-derby-test", "ukelonn"));
    }

what I got from maven, was:
 Running no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
 SLF4J: Defaulting to no-operation (NOP) logger implementation
 SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
 Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException: No Karaf main found
         at org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:85)
 Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 182.318 sec <<< FAILURE! - in no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
 no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed: 182.015 sec  <<< ERROR!
 java.lang.RuntimeException: Cannot get the remote bundle context
 Caused by: java.rmi.NotBoundException: bfa21964-9d13-4a55-b633-f0bc4368077a
 
 no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time elapsed: 182.318 sec  <<< ERROR!
 java.lang.RuntimeException: Container never came up
         at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
         at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
         at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
         at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)

so there is probably something missing from my setup.

For now, I will go back to the surefire config (it saves me the job of
manually killing the leftover java processes, and gets further before
it fails).

> if you are brave, you may want to take a look at the pax-web integration
> tests with Karaf. [1]
> Maybe there are enough hints for you to find out where exactly is your
> mismatch :)

> [1] - https://github.com/ops4j/org.ops4j.pax.web/tree/master/pax-web-itest/pax-web-itest-karaf/src/test/java/org/ops4j/pax/web/itest/karaf

Thanks for the tip! I will keep looking.
And post the reason when/if I find it (or find a workaround).


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Achim Nierbeck <bc...@googlemail.com>.
totally different ;)

if you are brave, you may want to take a look at the pax-web integration
tests with Karaf. [1]
Maybe there are enough hints for you to find out where exactly is your
mismatch :)

regards, Achim

[1] -
https://github.com/ops4j/org.ops4j.pax.web/tree/master/pax-web-itest/pax-web-itest-karaf/src/test/java/org/ops4j/pax/web/itest/karaf

2017-04-15 16:00 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> Achim Nierbeck <bc...@googlemail.com>:
>
> > the karaf container is always a forked process. If you want to run it as
> > non-forked you can use the following configuration:
>
> > runEmbedded(true)
>
> > this is especially useful if you want to debug your tests, but beware
> > because of the nature of how the tests run, this can only be used with
> > debugging and one test-method.
>
> Right.
>
> In the meantime I've found this thread
>  http://karaf.922171.n3.nabble.com/Pax-exam-tests-fail-to-
> start-properly-with-Karaf-4-0-4-tp4044841p4044843.html
>
> and have applied the same cure:
>     <plugin>
>      <groupId>org.apache.maven.plugins</groupId>
>      <artifactId>maven-surefire-plugin</artifactId>
>      <configuration>
>       <forkCount>0</forkCount>
>      </configuration>
>     </plugin>
>
> And that works... that is: it still doesn't start, but at least there
> isn't a Java VM still running after the test has failed.
>
> Does this the trigger the same behaviour as the runEmbedded(true)
> configuration? Or is that a competely different mechanism?
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:

> the karaf container is always a forked process. If you want to run it as
> non-forked you can use the following configuration:

> runEmbedded(true)

> this is especially useful if you want to debug your tests, but beware
> because of the nature of how the tests run, this can only be used with
> debugging and one test-method.

Right.

In the meantime I've found this thread
 http://karaf.922171.n3.nabble.com/Pax-exam-tests-fail-to-start-properly-with-Karaf-4-0-4-tp4044841p4044843.html

and have applied the same cure:
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <configuration>
      <forkCount>0</forkCount>
     </configuration>
    </plugin>

And that works... that is: it still doesn't start, but at least there
isn't a Java VM still running after the test has failed.

Does this the trigger the same behaviour as the runEmbedded(true)
configuration? Or is that a competely different mechanism?


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

the karaf container is always a forked process. If you want to run it as
non-forked you can use the following configuration:

runEmbedded(true)

this is especially useful if you want to debug your tests, but beware
because of the nature of how the tests run, this can only be used with
debugging and one test-method.

regards, Achim


2017-04-15 14:57 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> Steinar Bang <sb...@dod.no>:
>
> > There is this output at the end of the "mvn clean install":
> > [ERROR] Failed to execute goal org.apache.maven.plugins:
> maven-surefire-plugin:2.19.1:test (default-test) on project
> ukelonn.tests: Execution default-test of goal org.apache.maven.plugins:
> maven-surefire-plugin:2.19.1:test failed: The forked VM terminated
> without properly saying goodbye. VM crash or System.exit called?
> > [ERROR] Command was cmd.exe /X /C ""C:\Program
> Files\Java\jdk1.8.0_121\jre\bin\java" -jar C:\Users\sbang\workspaces\
> ws06\ukelonn\ukelonn.tests\target\surefire\surefirebooter5197692333401719291.jar
> C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefire8860295739440543272tmp
> C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\
> target\surefire\surefire_05835872688929628334tmp"
>
> > Obviously maven thinks the process has terminated.  Just as obviously
> > there is still a java process running (that prevents delete of the
> > target\exam directory structure).
>
> The documentation says "With the Forked Container, the system under test
> runs in a separate Java virtual machine under remote control from the
> test driver."
>  https://ops4j1.jira.com/wiki/display/PAXEXAM4/Pax+Exam
>
> How do I figure out whether I'm running a "forked container" or not?
>
> Is the mentioned "forked VM" in the rror message that has terminated,
> the VM actually running the tests? (ie. the single VM started in a
> "non-forked container" (or whatever it is called)...?).
>
> Or is the "forked VM" of the error message the front end that forks yet
> another VM to do the job, and it's this second VM that is left running?
> (ie. the "forked VM" of the error message is a VM started by maven
> surefire, and this VM runs a "forked container" that starts yet another
> VM where karaf is started and tests are run)
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> There is this output at the end of the "mvn clean install":
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project ukelonn.tests: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
> [ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_121\jre\bin\java" -jar C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefirebooter5197692333401719291.jar C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefire8860295739440543272tmp C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefire_05835872688929628334tmp"

> Obviously maven thinks the process has terminated.  Just as obviously
> there is still a java process running (that prevents delete of the
> target\exam directory structure).

The documentation says "With the Forked Container, the system under test
runs in a separate Java virtual machine under remote control from the
test driver."
 https://ops4j1.jira.com/wiki/display/PAXEXAM4/Pax+Exam

How do I figure out whether I'm running a "forked container" or not?

Is the mentioned "forked VM" in the rror message that has terminated,
the VM actually running the tests? (ie. the single VM started in a
"non-forked container" (or whatever it is called)...?).

Or is the "forked VM" of the error message the front end that forks yet
another VM to do the job, and it's this second VM that is left running?
(ie. the "forked VM" of the error message is a VM started by maven
surefire, and this VM runs a "forked container" that starts yet another
VM where karaf is started and tests are run)


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> Also there is a java process left running when the test completes with
> error, so there is some cleanup missing from the test setup (I have to
> kill that process to be allowed to run the test again. If not, windows
> file locking prevents "mvn clean" from deleting the target/exam
> directory structure).  

There is this output at the end of the "mvn clean install":
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project ukelonn.tests: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_121\jre\bin\java" -jar C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefirebooter5197692333401719291.jar C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefire8860295739440543272tmp C:\Users\sbang\workspaces\ws06\ukelonn\ukelonn.tests\target\surefire\surefire_05835872688929628334tmp"

Obviously maven thinks the process has terminated.  Just as obviously
there is still a java process running (that prevents delete of the
target\exam directory structure).


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>> Best to add the feature repository in your own feature and declare a
>> feature dependency to it. [1]
>> [1] - https://github.com/ANierbeck/Karaf-Vertx/blob/master/Vertx-Microservices/Vertx-Microservices-Features/src/main/feature/feature.xml#L21
>> [2] - https://ops4j1.jira.com/wiki/display/PAXJDBC/Documentation

> Ok, will try.

> But I'm still curious why running karaf in the integration tests is
> different to actually running in karaf..? :-)

I added pax-jdbc feature repository to the feature template file of my
db feature, ie. https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.bundle.test.db/src/main/feature/feature.xml

The resulting feature file built by maven looks like this:
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="ukelonn.bundle.test.db">
     <repository>mvn:org.ops4j.pax.jdbc/pax-jdbc-features/0.9.0/xml/features</repository>
     <repository>mvn:no.priv.bang.ukelonn/ukelonn.api/1.0.0-SNAPSHOT/xml/features</repository>
     <feature name="ukelonn-db-derby-test" description="Ukelonn webapp derby test database OSGi bundle" version="1.0.0.SNAPSHOT">
         <feature prerequisite="false" dependency="false">pax-jdbc</feature>
         <feature prerequisite="false" dependency="false">pax-jdbc-derby</feature>
         <feature version="1.0.0.SNAPSHOT" prerequisite="false" dependency="false">ukelonn-api</feature>
         <bundle start-level="80">mvn:no.priv.bang.ukelonn/ukelonn.bundle.test.db/1.0.0-SNAPSHOT</bundle>
     </feature>
 </features>

However I still get the same error on the pax exam karaf startup:
2017-04-15 11:08:35,327 | ERROR | pool-6-thread-1  | BootFeaturesInstaller            | 6 - org.apache.karaf.features.core - 4.0.7 | Error installing boot features
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=ukelonn-db-derby-test; type=karaf.feature; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; filter:="(&(osgi.identity=ukelonn-db-derby-test)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))" [caused by: Unable to resolve ukelonn-db-derby-test/1.0.0.SNAPSHOT: missing requirement [ukelonn-db-derby-test/1.0.0.SNAPSHOT] osgi.identity; osgi.identity=pax-jdbc; type=karaf.feature]
        at org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)[6:org.apache.karaf.features.core:4.0.7]
        at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:235)[6:org.apache.karaf.features.core:4.0.7]
        at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:158)[6:org.apache.karaf.features.core:4.0.7]
        at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:216)[6:org.apache.karaf.features.core:4.0.7]
        at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[6:org.apache.karaf.features.core:4.0.7]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176)[6:org.apache.karaf.features.core:4.0.7]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)[6:org.apache.karaf.features.core:4.0.7]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
[SUREFIRE] std/in stream corrupted
java.io.IOException: Command NOOP unexpectedly read Void data with length 4.
        at org.apache.maven.surefire.booter.MasterProcessCommand.decode(MasterProcessCommand.java:139)
        at org.apache.maven.surefire.booter.CommandReader$CommandRunnable.run(CommandReader.java:360)
        at java.lang.Thread.run(Thread.java:745)

Also there is a java process left running when the test completes with
error, so there is some cleanup missing from the test setup (I have to
kill that process to be allowed to run the test again. If not, windows
file locking prevents "mvn clean" from deleting the target/exam
directory structure).  

I'm studying the examples to try to figure out what I've missed.


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:

> the pax-jdbc feature isn't part of the std. feature set of Karaf, you have
> to add that dependency yourself.

Ok.

Out of curiosity: how is the pax jdbc found when I install the feature
on a regular karaf?

The procedure I use is the one here: https://github.com/steinarb/ukelonn/tree/using-vaadin#kjring-p-apache-karaf-med-testdatabasen

Translation of the essentials from the Norwegian text of the README:
 1. Clone and build the webapp
 2. Download and upack karaf 4.0.9 (The README says 4.0.7, but I just
    tried karaf 4.0.9 and that worked fine. I'm in the progress of
    moving to 4.1.1 (which requires work))
 3. Start the unpacked karaf and install the feature repository built
    from the webapp
      feature:repo-add mvn:no.priv.bang.ukelonn/ukelonn.karaf/LATEST/xml/features
 4. Install the required features
      feature:install ukelonn-db-derby-test
      feature:install ukelonn

I just tried this with a clean karaf 4.0.9 download and unpack, so I can
verify that it works.

The "feature:install ukelonn-db-derby-test" pulls in the necessary
features.  In the feature template file I haven't specified any feature
repository:
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.bundle.test.db/src/main/feature/feature.xml

Here's what's pulled in by ukelonn-db-derby-test:
 karaf@root()> feature:install ukelonn-db-derby-test
 karaf@root()> bundle:list
 START LEVEL 100 , List Threshold: 50
 ID | State  | Lvl | Version               | Name
 -----------------------------------------------------------------------------------------------
 52 | Active |  80 | 10.11.1000001.1616546 | Apache Derby 10.11
 53 | Active |  80 | 1.0.0.SNAPSHOT        | Ukelonn webapp OSGi service definitions OSGi bundle
 54 | Active |  80 | 1.0.0.SNAPSHOT        | Ukelonn webapp derby test database OSGi bundle
 55 | Active |  80 | 1.5.0                 | OPS4J Base - Service Provider Access
 56 | Active |  80 | 1.0.1                 | OPS4J Pax JDBC Generic Driver Extender
 57 | Active |  80 | 1.0.1                 | OPS4J Pax JDBC Apache Derby Driver Adapter
 58 | Active |  80 | 1.0.0.201505202023    | org.osgi:org.osgi.service.jdbc

> Best to add the feature repository in your own feature and declare a
> feature dependency to it. [1]

Ok, will try.

But I'm still curoious why running karaf in the integration tests is
different to actually running in karaf..? :-)

> regards, Achim

> [1] - https://github.com/ANierbeck/Karaf-Vertx/blob/master/Vertx-Microservices/Vertx-Microservices-Features/src/main/feature/feature.xml#L21
> [2] - https://ops4j1.jira.com/wiki/display/PAXJDBC/Documentation


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

the pax-jdbc feature isn't part of the std. feature set of Karaf, you have
to add that dependency yourself.
Best to add the feature repository in your own feature and declare a
feature dependency to it. [1]

regards, Achim

[1] -
https://github.com/ANierbeck/Karaf-Vertx/blob/master/Vertx-Microservices/Vertx-Microservices-Features/src/main/feature/feature.xml#L21
[2] - https://ops4j1.jira.com/wiki/display/PAXJDBC/Documentation

2017-04-15 9:40 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> Steinar Bang <sb...@dod.no>:
>
> > The next problem seems to be missing feature requirements.  Is this
> > because the pax exam test is running a minimal karaf installation? Do I
> > need to "preload" some features?
>
> I tried adding first just the standard feature repository, but that
> didn't change the error message.
>
> Then I tried adding the standard feature repository, and then load the
> (presumably missing) pax-jdbc feature from that, but that didn't help
> either, I got the same error message:
>     @Configuration
>     public Option[] config() {
>         final MavenArtifactUrlReference karafUrl =
> maven().groupId("org.apache.karaf").artifactId("apache-
> karaf-minimal").type("zip").versionAsInProject();
>         final MavenArtifactUrlReference karafStandrdRepo =
> maven().groupId("org.apache.karaf.features").artifactId("
> standard").versionAsInProject().type("xml").classifier("features");
>         final MavenArtifactUrlReference ukelonnFeatureRepo =
> maven().groupId("no.priv.bang.ukelonn").artifactId("ukelonn.
> karaf").versionAsInProject().type("xml").classifier("features");
>         return options(
>             karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new
> File("target/exam")).useDeployFolder(false),
>             configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
>             features(karafStandrdRepo, "pax-jdbc"),
>             features(ukelonnFeatureRepo, "ukelonn-db-derby-test",
> "ukelonn"));
>     }
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> The next problem seems to be missing feature requirements.  Is this
> because the pax exam test is running a minimal karaf installation? Do I
> need to "preload" some features?

I tried adding first just the standard feature repository, but that
didn't change the error message.

Then I tried adding the standard feature repository, and then load the
(presumably missing) pax-jdbc feature from that, but that didn't help
either, I got the same error message:
    @Configuration
    public Option[] config() {
        final MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf-minimal").type("zip").versionAsInProject();
        final MavenArtifactUrlReference karafStandrdRepo = maven().groupId("org.apache.karaf.features").artifactId("standard").versionAsInProject().type("xml").classifier("features");
        final MavenArtifactUrlReference ukelonnFeatureRepo = maven().groupId("no.priv.bang.ukelonn").artifactId("ukelonn.karaf").versionAsInProject().type("xml").classifier("features");
        return options(
            karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new File("target/exam")).useDeployFolder(false),
            configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
            features(karafStandrdRepo, "pax-jdbc"),
            features(ukelonnFeatureRepo, "ukelonn-db-derby-test", "ukelonn"));
    }


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> Here is the console output (I'm confused both by the "Unknown protocol:
> wrap" messages and the "error downloading" messages.  Both jars are
> present in ~/.m2/repository):

Ok, the answer to that one was a google search away: http://stackoverflow.com/a/35291578

I added "<feature prerequisite="true">wrap</feature>" to the webapps
main feature template file, and I got past the problems with loading the
wrapped jars: 
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.bundle/src/main/feature/feature.xml
(I put "<feature prerequisite="true">wrap</feature>" as the first
required feature here)

The next problem seems to be missing feature requirements.  Is this
because the pax exam test is running a minimal karaf installation? Do I
need to "preload" some features?

From the console:
2017-04-15 08:31:56,135 | ERROR | pool-6-thread-1  | BootFeaturesInstaller            | 6 - org.apache.karaf.features.core - 4.0.7 | Error installing boot features
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=ukelonn-db-derby-test; type=karaf.feature; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; filter:="(&(osgi.identity=ukelonn-db-derby-test)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))" [caused by: Unable to resolve ukelonn-db-derby-test/1.0.0.SNAPSHOT: missing requirement [ukelonn-db-derby-test/1.0.0.SNAPSHOT] osgi.identity; osgi.identity=pax-jdbc; type=karaf.feature]
	at org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:235)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:158)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:216)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)[6:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[:1.8.0_121]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_121]


Re: Is there a recent pax exam karaf provisioning example somewhere?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> Since I have been using karaf for the last 6 months or so, it would be a
> good idea to convert the pax exam tests
>  https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java
> to karaf provisioning (so that I can use the features and not have to
> figure out individual bundles on my own).

With help from the list, the above test have the following options,
right now (not checked in or pushed, yet):
    @Configuration
    public Option[] config() {
        final MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf-minimal").type("zip").versionAsInProject();
        final MavenArtifactUrlReference ukelonnFeatureRepo = maven().groupId("no.priv.bang.ukelonn").artifactId("ukelonn.karaf").versionAsInProject().type("xml").classifier("features");
        return options(
            karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new File("target/exam")).useDeployFolder(false),
            configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
            features(ukelonnFeatureRepo, "ukelonn-db-derby-test", "ukelonn"));
    }

With this, it starts and then fails.  The stack trace in the unit test
complains about
 Caused by: java.rmi.NotBoundException: 051fb5cd-af1b-4b9b-b1a7-00b8600e3a0d

The console output complains about the two non-bundle jars that karaf
wraps on the fly (this works when I'm running in regular karaf).

FWIW I have rebundled versions of the two jars available. They are what
I've been using in the integration tests up until now:
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.rebundled/ukelonn.rebundled.com.vaadin.addon.vaadin-touchkit-agpl/pom.xml
 https://github.com/steinarb/ukelonn/blob/using-vaadin/ukelonn.rebundled/ukelonn.rebundled.com.vaadin.external.gwt.gwt-user/pom.xml
(but I thought I could throw these away when moving to karaf based
integration tests).

Here is the console output (I'm confused both by the "Unknown protocol:
wrap" messages and the "error downloading" messages.  Both jars are
present in ~/.m2/repository):

2017-04-15 07:48:08,261 | ERROR | pool-6-thread-1  | BootFeaturesInstaller            | 6 - org.apache.karaf.features.core - 4.0.7 | Error installing boot features
org.apache.karaf.features.internal.util.MultiException: Error
	at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.<init>(MavenDownloadManager.java:84)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.download.impl.MavenDownloadManager.createDownloader(MavenDownloadManager.java:72)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:363)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:360)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:187)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)[6:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[:1.8.0_121]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_121]
Caused by: java.io.IOException: Error downloading wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/addon/vaadin-touchkit-agpl/4.1.0/vaadin-touchkit-agpl-4.1.0.jar
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:67)[6:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)[:1.8.0_121]
	... 3 more
Caused by: java.io.IOException: Could not download [wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/addon/vaadin-touchkit-agpl/4.1.0/vaadin-touchkit-agpl-4.1.0.jar]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:90)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:58)[6:org.apache.karaf.features.core:4.0.7]
	... 7 more
Caused by: java.net.MalformedURLException: Unknown protocol: wrap
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:62)[6:org.apache.karaf.features.core:4.0.7]
	... 8 more
Caused by: java.lang.IllegalStateException: Unknown protocol: wrap
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)[org.apache.felix.framework-5.4.0.jar:]
	... 12 more
Caused by: java.io.IOException: Error downloading wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/addon/vaadin-touchkit-agpl/4.1.0/vaadin-touchkit-agpl-4.1.0.jar
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:67)[6:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)[:1.8.0_121]
	... 3 more
Caused by: java.io.IOException: Could not download [wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/addon/vaadin-touchkit-agpl/4.1.0/vaadin-touchkit-agpl-4.1.0.jar]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:90)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:58)[6:org.apache.karaf.features.core:4.0.7]
	... 7 more
Caused by: java.net.MalformedURLException: Unknown protocol: wrap
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:62)[6:org.apache.karaf.features.core:4.0.7]
	... 8 more
Caused by: java.lang.IllegalStateException: Unknown protocol: wrap
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)[org.apache.felix.framework-5.4.0.jar:]
	... 12 more
Caused by: java.io.IOException: Error downloading wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/external/gwt/gwt-user/2.7.0.vaadin4/gwt-user-2.7.0.vaadin4.jar
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:67)[6:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)[:1.8.0_121]
	... 3 more
Caused by: java.io.IOException: Could not download [wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/external/gwt/gwt-user/2.7.0.vaadin4/gwt-user-2.7.0.vaadin4.jar]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:90)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:58)[6:org.apache.karaf.features.core:4.0.7]
	... 7 more
Caused by: java.net.MalformedURLException: Unknown protocol: wrap
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:62)[6:org.apache.karaf.features.core:4.0.7]
	... 8 more
Caused by: java.lang.IllegalStateException: Unknown protocol: wrap
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)[org.apache.felix.framework-5.4.0.jar:]
	... 12 more
Caused by: java.io.IOException: Error downloading wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/external/gwt/gwt-user/2.7.0.vaadin4/gwt-user-2.7.0.vaadin4.jar
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:67)[6:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)[:1.8.0_121]
	... 3 more
Caused by: java.io.IOException: Could not download [wrap:file:/C:/Users/sbang/.m2/repository/com/vaadin/external/gwt/gwt-user/2.7.0.vaadin4/gwt-user-2.7.0.vaadin4.jar]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:90)[6:org.apache.karaf.features.core:4.0.7]
	at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:58)[6:org.apache.karaf.features.core:4.0.7]
	... 7 more
Caused by: java.net.MalformedURLException: Unknown protocol: wrap
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at java.net.URL.<init>(Unknown Source)[:1.8.0_121]
	at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:62)[6:org.apache.karaf.features.core:4.0.7]
	... 8 more
Caused by: java.lang.IllegalStateException: Unknown protocol: wrap
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)[org.apache.felix.framework-5.4.0.jar:]
	... 12 more