This would be my advice too.

-> richard

-----Original Message-----

From:  Marcel Offermans <[EMAIL PROTECTED]>
Subj:  Re: [Maven] Bundle runner mojo problems
Date:  Sun 13. Aug 2006 6:08
Size:  3K
To:  [email protected]

Hi Alex,

The class cast exception indicates there are two different copies on  
the class path. Since you did not post exactly how you started up,  
I'd have to guess what's going on...

..but, I would like to ask you why you are extending Felix like  
this? I see at least two other approaches that I would favor:

1) Keeping this as a bundle. What you're doing is essentially (in  
OSGi speak) installing a (simple) management agent. This agent is  
then responsible for installing and starting bundles.

2) Keeping it as a "bundle" that loads as part of the system bundle.  
Felix has a nice mechanism to provide zero or more extensions to the  
system bundle by means of providing classes that implement  
BundleActivator. Package your stuff like that and my guess is it runs  
without any modifications (compared to running it as 1) which is  
something you've already tried.

Furthermore, if you're concerned about having to specify all kinds of  
startup options to fire up this management bundle, it's fairly easy  
to create a wrapper startup class that sets all options (as system  
properties) and subsequently starts Felix (which will then pick those  
up and auto start your "management agent" bundle that will then start  
the rest).

I'm guessing you're doing this to create some kind of automated test  
framework?

I would very much prefer option 1) because that is the one that is  
the easiest to "port" to other frameworks.

But, this is a lot of guesswork and brainstorming, so I might not  
understand the problem you're trying to solve at all. :)

Greetings, Marcel

On Aug 13, 2006, at 7:01 , Alex Karasulu wrote:

> 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 );
>     b.start();
>
> 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.createBundleActivator 
> (Felix.java:2702)
>         at org.apache.felix.framework.Felix._startBundle(Felix.java: 
> 1203)
>         ... 3 more
>
>
> Thanks,
> Alex


--- message truncated ---

Reply via email to