felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <aok...@bellsouth.net>
Subject [Maven] Bundle runner mojo problems
Date Sun, 13 Aug 2006 05:01:54 GMT
Hi folks,

I've been trying to figure out a way to tell Felix how to 
programmatically install and start bundles.  My goal is to build a 
simple mojo for our maven 2 plugin that will allow us to install and 
start a bundle produced by a project using Felix.  This idea is to use a 
command like so:

mvn osgi:run

This will trigger the mojo to startup Felix, install and start the 
target bundle generated by the project including any dependent bundles.

My problem is in navigating the Felix API.  I would like to avoid using 
the configuration file all together and just use the API.  What I've 
done is extended Felix and exposed the protected installBundle method. 
Next I called it to get a handle on a Bundle and called start() on it. 
Here's how that code looks ...

     in = new FileInputStream( 
"/home/akarasulu/test-bundle-1.0.0-SNAPSHOT.jar" );
     b = instance.installBundle( 
"file:///home/akarasulu/test-bundle-1.0.0-SNAPSHOT.jar", in );

Instance is the instance of the Felix subclass.  When I do this I get a 
ClassCastException on the BundleActivator in this simple bundle which 
just prints Hello World.  The bundle starts just fine in Felix running 
in standard command line mode.  I'm just wondering what I'm doing wrong. 
  Any hints or suggestions on what I'm botching up would be great.

Here's the stack trace that I get:

Exception in thread "main" org.osgi.framework.BundleException: Activator 
start error.
         at org.apache.felix.framework.Felix._startBundle(Felix.java:1261)
         at org.apache.felix.framework.Felix.startBundle(Felix.java:1149)
         at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:326)
         at FelixTestDriver.main(FelixTestDriver.java:65)
Caused by: java.lang.ClassCastException: test.Activator
         at org.apache.felix.framework.Felix._startBundle(Felix.java:1203)
         ... 3 more


View raw message