Debug from eclipse and bnd-testing-maven-plugin

321 views
Skip to first unread message

Matteo Rulli

unread,
Jan 9, 2017, 6:21:24 PM1/9/17
to bndtools-users
I created an integration-test project based on maven and bnd-testing-maven-plugin (v. 3.4.0-SNAPSHOT). In the project's bnd file I put the 
Test-Cases: ${classes;NAMED;*Test} header and in the bndrun file I used the aQute.bnd.repository.maven.pom.provider.BndPomRepository to turn the project pom into a repository to resolve the bundles that I need for my integration test. 

If I now run "mvn install" from the command line, the integration test starts as expected.

Now I would also like to debug the integration test from eclipse: I naively tried with "Debug As/Bnd OSGi Test Launcher (JUnit)" from the bndrun file. Unfortunately I get the following error:

Launch configuration itest.bndrun references non-existing project cnf.

I cannot understand this message: I put the -standalone: header in my bndrun file exactly to avoid creating the cnf project. In any case, even if I create the cnf project, the error persists.

What is the right way to develop integration tests with pure maven approach and to debug integration tests with eclipse at the same time? Is it possible to get rid of the error above?

Thanks,
matteo

Raymond Auge

unread,
Jan 9, 2017, 10:35:45 PM1/9/17
to bndtool...@googlegroups.com
Greg fixed that issue just before the holidays so I would update to the most recent build of bndtools from ccloudbees.

- Ray

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matteo Rulli

unread,
Jan 10, 2017, 3:13:52 AM1/10/17
to bndtools-users
Ray, thank you! 
I was using the last snapshot for the maven plugins but I still had the 3.3.0 in eclipse. Updating the eclipse plugin to 3.4.0 SNAPSHOT did the trick :o)

Unfortunately, although test case is now executed without errors within eclipse, I still cannot hit breakpoints. Besides, when I run the "mvn install" command from the parent pom, the test completes successfully but the overall maven build process fails with errors like this:

Tests run  : 1

Passed     : 1

Errors     : 0

Failures   : 0

# test ran

# queue []

[ERROR] Terminal initialization failed; falling back to unsupported

java.lang.IllegalStateException: Shutdown in progress

at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)

at java.lang.Runtime.addShutdownHook(Runtime.java:211)

at jline.internal.ShutdownHooks.addHook(ShutdownHooks.java:79)

at jline.internal.ShutdownHooks.add(ShutdownHooks.java:43)

at jline.TerminalSupport.init(TerminalSupport.java:49)

at jline.UnixTerminal.init(UnixTerminal.java:78)

at jline.TerminalFactory.create(TerminalFactory.java:122)

at jline.TerminalFactory.get(TerminalFactory.java:186)

at jline.TerminalFactory.get(TerminalFactory.java:192)

at osgi.enroute.gogo.shell.provider.Shell$1.run(Shell.java:153)

at java.lang.Thread.run(Thread.java:745)


java.lang.RuntimeException: Failed to initialise terminal: 

at osgi.enroute.gogo.shell.provider.Shell$1.run(Shell.java:157)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.IllegalStateException: Shutdown in progress

at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)

at java.lang.Runtime.addShutdownHook(Runtime.java:211)

at jline.internal.ShutdownHooks.addHook(ShutdownHooks.java:79)

at jline.internal.ShutdownHooks.add(ShutdownHooks.java:43)

at jline.TerminalSupport.init(TerminalSupport.java:49)

at osgi.enroute.gogo.shell.provider.Shell$1.run(Shell.java:155)

... 1 more

Errors

Cannot find /error/org.apache.karaf.jaas:org.apache.karaf.jaas.boot;version=4.0.6 Not found in [bnd-cache, com.flairbit.example.persistence]

Cannot find /error/org.apache.karaf.features:org.apache.karaf.features.core;version=4.0.6 Not found in [bnd-cache, com.flairbit.example.persistence]

Cannot find /error/org.ops4j.pax.logging:pax-logging-api;version=1.8.5 Not found in [bnd-cache, com.flairbit.example.persistence]

...


This is strange as all the bundles it is complaining about are indeed present in the com.flairbit.example.persistence repo (it is the repo that is generated by BndPomRepository).

Thanks,
matteo

On Tuesday, January 10, 2017 at 4:35:45 AM UTC+1, Raymond Auge wrote:
Greg fixed that issue just before the holidays so I would update to the most recent build of bndtools from cloudbees.

- Ray

On Jan 9, 2017 6:21 PM, "Matteo Rulli" <matteo...@gmail.com> wrote:
I created an integration-test project based on maven and bnd-testing-maven-plugin (v. 3.4.0-SNAPSHOT). In the project's bnd file I put the 
Test-Cases: ${classes;NAMED;*Test} header and in the bndrun file I used the aQute.bnd.repository.maven.pom.provider.BndPomRepository to turn the project pom into a repository to resolve the bundles that I need for my integration test. 

If I now run "mvn install" from the command line, the integration test starts as expected.

Now I would also like to debug the integration test from eclipse: I naively tried with "Debug As/Bnd OSGi Test Launcher (JUnit)" from the bndrun file. Unfortunately I get the following error:

Launch configuration itest.bndrun references non-existing project cnf.

I cannot understand this message: I put the -standalone: header in my bndrun file exactly to avoid creating the cnf project. In any case, even if I create the cnf project, the error persists.

What is the right way to develop integration tests with pure maven approach and to debug integration tests with eclipse at the same time? Is it possible to get rid of the error above?

Thanks,
matteo

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

Matteo Rulli

unread,
Jan 11, 2017, 5:09:23 AM1/11/17
to bndtools-users
Ok, I now managed to hit the breakpoint within eclipse. I did that leveraging these suggestions: https://github.com/bndtools/bnd/tree/master/maven/bnd-indexer-maven-plugin#including-the-current-project-output-as-part-of-the-index.

So the overall situation is now the following:

- Combining the bnd-testing-maven-plugin and the bnd-indexer-maven-plugin I'm now able to debug my integration test within eclipse using the "Debug As/Bnd OSGi Test Launcher (JUnit)" from the bndrun file: the trivial integration test I run completes successfully within eclipse;
- The same test fails if it is triggered through the "mvn install" command with the error already reported
- By the way, the bnd-testing-maven-plugin apparently ignores the -Dmaven.test.skip=true possible directive. Is that normal?

I pushed a project to reproduce the issue on github: https://github.com/mrulli/com.flairbit.examples.mvnosgi

Thanks for your help,
matteo

Timothy Ward

unread,
Jan 11, 2017, 5:18:53 AM1/11/17
to bndtool...@googlegroups.com
- By the way, the bnd-testing-maven-plugin apparently ignores the -Dmaven.test.skip=true possible directive. Is that normal?

This is “normal” as the bnd integration tests aren’t run by the surefire plugin which would normally interpret that property. We should probably take the property into account though - can you raise a separate bug for it?

Matteo Rulli

unread,
Jan 11, 2017, 5:37:10 AM1/11/17
to bndtools-users

Matteo Rulli

unread,
Jan 11, 2017, 8:05:19 AM1/11/17
to bndtools-users
Ok, I think I managed to boil down the problem. I had a couple of issues in my bndrun file and that generated most of the confusion. 

The real point is that I need to specify some non-OSGi artifacts in the -runpath header within the itest.bndrun. In bndtools projects I can do that using the

aQute.bnd.repository.maven.provider.MavenBndRepository plugin: it is enough to specify those artifacts in the mvn file and then it is possible to use them in the runpath using the mavengroup:artifactId;version= syntax. Is there a way to do that with the pure maven approach? I suspect I cannot use the MavenBndRepository in pure maven projects, right?


Thank you,

matteo

Matteo Rulli

unread,
Jan 11, 2017, 8:35:19 AM1/11/17
to bndtools-users
Hey, 
it is possible to use the MavenBndRepository in pure maven projects! Wow, that's really nice. Problem solved.

Thank you Raymond and Tim for the help.

m

Raymond Auge

unread,
Jan 11, 2017, 11:04:31 AM1/11/17
to bndtool...@googlegroups.com
Would you share your configuration for posterity? :)

- Ray

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

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



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

Matteo Rulli

unread,
Jan 11, 2017, 11:10:01 AM1/11/17
to bndtools-users
I was thinking to write an app note for the enRoute web site, what do you think?

I have just to clean a little bit the current project and then I'll publish it on github as well.

matteo

Raymond Auge

unread,
Jan 11, 2017, 11:19:00 AM1/11/17
to bndtool...@googlegroups.com
Perfect! :)

- Ray

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages