Bndtools, Maven, and Eclipse

303 views
Skip to first unread message

Tristan Bull

unread,
Sep 28, 2015, 10:20:55 AM9/28/15
to bndtools-users
Hello all,

I am looking at converting a large maven/tycho project into a maven/bnd project. We currently use PDE for Eclipse development, and I would like to use Bndtools for Eclipse development in the future. I looked into this about a year ago, and made some progress with the old bnd-maven-plugin, but ultimately abandoned the conversion due to time constraints. We're fed up with Tycho/PDE so I'm back at it again.

I found this post by Neil Bartlett and this example. This project builds fine with Maven. However, I don't see how to build the project in Eclipse. if I import the project into Eclipse I have build errors: "Eclipse doesn't know what to do with the No marketplace entries found to handle bnd-maven-plugin:2.4.1:bnd-process in Eclipse."

I'm also unable to import the example into eclipse as a standard project since there are no project files and no cnf project. So my question is, what is the proper development path for the Maven-Bndtools-Eclipse toolchain? Thanks!

Neil Bartlett

unread,
Sep 28, 2015, 10:36:47 AM9/28/15
to bndtool...@googlegroups.com
Tristan,

You should first upgrade to bnd-maven-plugin version 3.0, which was released earlier this month (obviously I need to upgrade the example project also… I will get on that). This fixes the error message from m2eclipse.

Second, since these are maven projects you must always import into Eclipse with the “Import existing maven projects” wizard. This will give you an environment in which you can develop OSGi bundles in Eclipse and build them with Maven. Unfortunately in 3.0, it is hard to use the Bndtools launching infrastructure to actually run an OSGi Framework with your bundles in it. This is the focus of our development work for 3.1. If you are willing to live at the bleeding edge, you will find the following features to help you out:

* An additional plugin, bnd-indexer-maven-plugin, can be used to generate an OSGi Repository index from a bunch of maven projects and their transitive dependencies.
* In bndtools, run descriptor files can be used in “standalone” mode, so a cnf project is not needed. You just need to point it at the URLs of one or more repository indexes, such as one generated by the aforementioned plugin.

However this is all in active development at the moment so it will take some time to become stable. If you don’t want to use the snapshots then will have to find another way to configure and launch OSGi runtimes.

Regards,
Neil


--
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.
For more options, visit https://groups.google.com/d/optout.

Tristan Bull

unread,
Sep 28, 2015, 10:57:26 AM9/28/15
to bndtools-users
Hi Neil,

Thanks for the quick response. I'm willing to run with snapshots for now, as being able to launch OSGi runtimes (specifically Felix runtimes) from Eclipse is a motivating factor behind our move from PDE/Tycho. I'll look into the the bnd-indexer-maven-plugin and these "standalone" run descriptors, and see if I can get them working with the sample project. You don't happen to have a sample project already demonstrating their use do you?

Tristan Bull

unread,
Sep 28, 2015, 12:26:13 PM9/28/15
to bndtools-users
Actually, I have a more specific question. Do you guys have a "snapshots" maven repository? 

The "bnd-indexer-maven-plugin" is not in maven central, which makes sense given that it's unreleased. I tried building locally, but it looks like it depends on other version 3.1.0 artifacts ("biz.aQute.bndlib") that are also not in maven central. So  presumably, I would need to build all of bnd and push those artifacts into my local maven repo before using the indexer plugin. Just wondering if there's a shortcut. Thanks again!

Timothy Ward

unread,
Sep 28, 2015, 1:24:20 PM9/28/15
to bndtool...@googlegroups.com
Hi Tristan,

I’m the person who’s done most of the indexer plugin work. The following may be helpful to you:

<pluginRepositories>
<pluginRepository>
<id>bnd-latest</id>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>

Note that bnd only ever builds “release capable versions” in our CI, so there is no snapshot in the maven version. This means that your local m2 repository will cache the development builds indefinitely because it sees them as “released" builds. You can get the latest plugin by deleting the entry from your local m2 and running your maven build again.

Once we do have a final release of bnd 3.1.0 then this plugin will go into maven central. If you really need it before then then please talk to us. If you are prepared to help with the work, then you may be able to convince the team to put out a bnd 3.0.1 release including the plugin and a few other fixes that have been made since 3.0.0.

Regards

Tim Ward


Tristan Bull

unread,
Sep 28, 2015, 1:48:04 PM9/28/15
to bndtools-users
Hi Tim,

I actually did try adding the plugin repository URL as you mentioned. However, in my build output I see the following:


Maven appears to be searching for a metadata xml file at "org/apache/maven/plugins/maven-metadata.xml" and "org/codehaus/mojo/maven-metadata.xml", and neither of these directories exist on your CI machine.  It seems that it should instead be looking for the metadata file here: https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/maven/target/m2/biz/aQute/bnd/maven-metadata-local.xml, but I'm not sure how to tell Maven that.

I would not want to ask for a 3.0.1 release until I could commit to helping with the project, which I can't do at this time.

Timothy Ward

unread,
Sep 28, 2015, 5:08:49 PM9/28/15
to bndtool...@googlegroups.com
Hi Tristan,

What version of maven are you using? I’m using 3.3.3 and the snippet I attached works for me. I’m actually using it to try out the indexer in some example code. It might help to check the pom configuration too - there are a number of examples in the integration tests for the bnd-indexer-maven-plugin.

Regards,

Tim Ward


Tristan Bull

unread,
Sep 29, 2015, 11:44:54 AM9/29/15
to bndtools-users
Hi Tim, I figured out the issue though. Unsurprisingly, it was operator error. I was trying to execute "mvn bnd-indexer-maven-plugin:index" which I thought would work because the plugin is defined in the pom, but that is not true. The plugin works fine if I execute a standard maven goal that includes the plugin. 

Thanks for the help!

Tristan Bull

unread,
Sep 29, 2015, 1:59:57 PM9/29/15
to bndtools-users
Alright, so I've got the index file building now. Has the "standalone" option been implemented yet in bndtools? I added the standalone parameter to a run file, and I get the following error when I attempt to launch the .bndrun file: "Launch configuration example.bndrun references non-existing project cnf." So it seems like it's still looking for a cnf project, rather than referencing the index?

Neil Bartlett

unread,
Sep 29, 2015, 2:04:29 PM9/29/15
to bndtool...@googlegroups.com
Yes it has been implemented. You will have to install the latest development build though.

Tristan Bull

unread,
Sep 29, 2015, 2:18:00 PM9/29/15
to bndtool...@googlegroups.com
I am on 3.1.0.DEV-201, which seems to be the latest version according to Eclipse. Is that true? What exactly is required in the standalone bndrun file? the samples in the integration tests here have only the standalone argument, but I thought that might just be because that's all that the tests are testing.

--
You received this message because you are subscribed to a topic in the Google Groups "bndtools-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bndtools-users/v5doZRx7Wbk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bndtools-user...@googlegroups.com.

Neil Bartlett

unread,
Sep 29, 2015, 4:37:02 PM9/29/15
to bndtool...@googlegroups.com
That version String looks truncated (it should have a date/time stamp at the end), but you’re probably on the right version.

I have one idea. Did you previous run this bndrun file (or try to run it) in an older version? When you launch a bndrun file for the first time, we create a “launch configuration” (Eclipse internal terminology). This launch config used to require a reference to a Java project, and so we used the cnf.  Unfortunately if you delete the cnf… bang.

You could try clearing the existing launch config by going to the main Eclipse menu and selecting Run -> Run Configurations. Find the matching entry in the selector on the left and just delete it. Then try to relaunch from your bndrun file.

Cross fingers that this will work.

Neil

Tristan Bull

unread,
Sep 30, 2015, 10:15:54 AM9/30/15
to bndtool...@googlegroups.com
Thanks Neil, you were correct. After deleting the run configuration, I was able to make some progress. Now, I see this error: 

Status ERROR: bndtools.core code=0 No OSGi framework has been added to the run path. null

Based on the contents of the index file, this makes sense. There's no felix-main, etc. in the index, and I'm not sure how to get it to show up in there since it's not a compile-time dependency of the project. I've attached my index if it's of any use, and FYI, I'm currently just playing around with this test project. I updated it to 3.1.0 without issue, and now I'm just trying to run it from eclipse.
index.xml

Timothy Ward

unread,
Sep 30, 2015, 10:45:31 AM9/30/15
to bndtool...@googlegroups.com
Hi Tristan,

You have a couple of options here:

  1. Create a second index which contains only org.apache.felix:org.apache.felix.framework:5.2.0 (or a framework of your choice). Probably best to use <includeTransitive>false</includeTransitive> in the configuration for this index. Include this as a second index in the same standalone header in your bndrun file.
  2. Add a runtime scoped dependency on the framework to your primary application index, so that the bndrun can run with a single index.


I prefer option 1 because it avoids polluting your application index with an OSGi framework implementation. For most OSGi provisioners the framework is  a provided dependency (i.e. implicit in the provisioning platform). In these scenarios you should never try to provision a framework from your index, so this option is the best choice as it has a clear separation of concerns, making it impossible to accidentally deploy another framework..

Option 2 has the advantage that you can use a single index when making your simple bndrun. If your intention is simply to use the bndrun to export executable jars from bnd/bndtools then option 2 is arguably more appropriate. In this case the bndrun really does have a runtime dependency on the OSGi framework implementation, so it should be in the index to ensure transitive completeness.

I hope this helps.

Tim Ward



<index.xml>

BJ Hargrave

unread,
Sep 30, 2015, 10:53:07 AM9/30/15
to bndtool...@googlegroups.com
On Sep 30, 2015, at 10:15 , Tristan Bull <tristan...@gmail.com> wrote:

Thanks Neil, you were correct. After deleting the run configuration, I was able to make some progress. Now, I see this error: 

Status ERROR: bndtools.core code=0 No OSGi framework has been added to the run path. null

I see a similar issue too. The bndtools 3.1 build is currently borked for launching. Not sure what is broken. I ran out of time to dig in to it.

When I try to Run as Bnd OSGi Test Launcher (Junit) on the org.osgi.impl.bundle.repoindex.test project, I get:

Exception in thread "main" java.lang.NoClassDefFoundError: org/osgi/framework/ServiceListener

which indicates that the framework was not placed on the classpath for the launch.

./gradlew :org.osgi.impl.bundle.repoindex.test:check 

works fine on the command line. So the issue must be somewhere in the bndtools launch logic.

<index.xml>

-- 

BJ



Neil Bartlett

unread,
Sep 30, 2015, 11:04:24 AM9/30/15
to bndtool...@googlegroups.com
Hi BJ,

It's working fine for me, so if you have any tips for reproducing the error could you add them to a bug report? 

Thanks.
Neil


BJ Hargrave

unread,
Sep 30, 2015, 11:08:48 AM9/30/15
to bndtool...@googlegroups.com
On Sep 30, 2015, at 11:04 , Neil Bartlett <njbar...@gmail.com> wrote:

Hi BJ,

It's working fine for me, so if you have any tips for reproducing the error could you add them to a bug report? 

I had installed a new Eclipse (using the Oomph installer), installed bndtools 3.1 from cloudbees. I then pointed it to my bnd workspace. I even deleted all the Run configurations. Otherwise nothing special. Not sure how to debug further. Did you try with a fresh Eclipse and bndtools install?
-- 

BJ



Tristan Bull

unread,
Sep 30, 2015, 11:49:34 AM9/30/15
to bndtool...@googlegroups.com
I followed Tim's first suggestion above, and I was able to get the run configuration to at least execute. I haven't been able to verify that my bundles were installed since I don't have the gogo shell or web console installed, but presumably if I add those to my new "runtime" index, I should be able to use them. Thanks for the help guys! I'm looking forward to seeing how this shakes out for 3.1.

Neil Bartlett

unread,
Sep 30, 2015, 3:01:45 PM9/30/15
to bndtool...@googlegroups.com
Hi BJ,

Okay I’ve reproduced the issue, and it’s even more severe than we thought. When launching from a bnd.bnd, *none* of the properties are read from the file. Things work fine if you launch from a *.bndrun file.

I’ll work on it later in the week.

Neil

BJ Hargrave

unread,
Sep 30, 2015, 3:04:57 PM9/30/15
to bndtool...@googlegroups.com
On Sep 30, 2015, at 15:01 , Neil Bartlett <njbar...@gmail.com> wrote:

Hi BJ,

Okay I’ve reproduced the issue, and it’s even more severe than we thought. When launching from a bnd.bnd, *none* of the properties are read from the file.

Glad you understand the problem!

Things work fine if you launch from a *.bndrun file.

Yes, I did notice that bndrun files worked fine. But of course, they are not supposed to inherit from the bnd.bnd file.


I’ll work on it later in the week.

Awesome! Peter will also be pleased as he encountered this also. Thanks.
Reply all
Reply to author
Forward
0 new messages