• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache Felix Tutorials

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to play around with Apache Felix but the tutorials do not seem to work very well for me. I shall explain what I'm doing and what I see (and don't see). Maybe someone here can lend a hand.


1. I downloaded the Apache Felix binary. I can start the framework up no problem.
2. I wrote this program:
http://felix.apache.org/site/apache-felix-tutorial-example-1.html
Then exported into a jar file named: testFelix.jar.
3. I then typed the following on the command line:
start file:/C:/Users/Me/Desktop/testFelix.jar
4. Which, I thought, would give me some output to the Felix console. But I see nothing. If I do a 'lb' I can see my bundle there.

This is what I see:

C:\Users\Me\Desktop\org.apache.felix.main.distribution-4.0.3\felix-framework-
4.0.3>java -jar bin/felix.jar
____________________________
Welcome to Apache Felix Gogo

g! start file:/C:/Users/Me/Desktop/testFelix.jar
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.0.3)
1|Active | 1|Apache Felix Bundle Repository (1.6.6)
2|Active | 1|Apache Felix Gogo Command (0.12.0)
3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
4|Active | 1|Apache Felix Gogo Shell (0.10.0)
5|Active | 1|file:/C:/Users/Me/Desktop/testFelix.jar (0.0.0)
g!



So after this, I thought to myself: Maybe this first example doesn't print anything out. So I'll write the next one.
5. So I wrote this program: http://felix.apache.org/site/apache-felix-tutorial-example-2.html and exported the jar as testFelix2.jar.
6. I then typed the following on the console, and saw yet again, blank output:

g! start file:/C:/Users/Me/Desktop/testFelix2.jar
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.0.3)
1|Active | 1|Apache Felix Bundle Repository (1.6.6)
2|Active | 1|Apache Felix Gogo Command (0.12.0)
3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
4|Active | 1|Apache Felix Gogo Shell (0.10.0)
5|Active | 1|file:/C:/Users/Me/Desktop/testFelix.jar (0.0.0)
7|Active | 1|file:/C:/Users/Me/Desktop/testFelix2.jar (0.0.0)
g!



So I'm not really sure what is going on here. There doesn't seem to be any error messages or whatnot and due to my lack of skill (yet), I'm not sure where to find out where the issue lies.

I am using the default config file for Felix. I'm not sure if that has anything to do with it.

Here is a question, which I just thought of: in the manifest file, it says this:


I have not actively downloaded anything like that - I've only grabbed the Apache Felix binary (felix.jar). Isn't that framework contained in Felix? AFAIK, OSGI is just a specification and not an implementation? (Once again showing my ignorance!)

So, if I do in fact, need to get this extra code, where would I find it from? The Felix download page doesn't seem to have anything that looks like it.

Thanks!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OSGi is the specification, and Felix the implementation. The Felix jar files contain all of the OSGi interfaces, so there's nothing else you need to download. You may want to bookmark this page, though - it's the javadocs of the OSGi API, which you'll need for development.

if I start the first example, it prints "Starting to listen for service events." and when I uninstall the service it prints "Stopped listening for service events." That's all that example does.

I also have the Apache Felix Shell Service and the Apache Felix Shell TUI bundles running, though. The file conf/config.properties tells Felix to start those automatically. I've had Felix installed for a long time, I don't recall if those were there from the beginning or if I added them later.

Running the second example does indeed cause more things to happen, provided I start both the Example English Dictionary and then the Example Dictionary Client bundles.
 
Joey Kirkland
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:OSGi is the specification, and Felix the implementation. The Felix jar files contain all of the OSGi interfaces, so there's nothing else you need to download. You may want to bookmark this page, though - it's the javadocs of the OSGi API, which you'll need for development.

if I start the first example, it prints "Starting to listen for service events." and when I uninstall the service it prints "Stopped listening for service events." That's all that example does.

I also have the Apache Felix Shell Service and the Apache Felix Shell TUI bundles running, though. The file conf/config.properties tells Felix to start those automatically. I've had Felix installed for a long time, I don't recall if those were there from the beginning or if I added them later.

Running the second example does indeed cause more things to happen, provided I start both the Example English Dictionary and then the Example Dictionary Client bundles.



Hi thanks for your reply.

It would seem that I have something completely messed up...as I don't see any of the output when I start these bundles.

Upon re-reading the first tutorial, it out at me that Felix never asked me for a profile name upon start up, so I never added them to the profile. I bet this is my issue right here. I will have to look around on their site to find out how I can do this.

Edit: Upon looking around, I can't find anything about profiles or how to set them, or how to have Felix prompt for them.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I gave it a quick test with the current Felix distribution. Here are a few observations:

  • Contrary to what the documentation says, I'm not being asked for a profile name. That doesn't seem to have any impact, though.


  • Note that issuing "install file:..." does install a bundle, but it does not start it. You need to do that manually by issuing "start N" (where N is the bundle ID as listed in the "lb" listing). Or you need to load the bundle by issuing "start file:..." which installs and starts in one step.


  • For Example1, I see the expected output when the bundle is started and stopped.


  • Example2 doesn't do anything by itself - it's just a service which you can test by installing and running Example3.


  • Other than the issue about not having to enter a "profile name", all three examples compile, run and install pretty much as described in the documentation.


  • Typing "lb" gives a handy overview of which bundles are installed, and which are running.
  •  
    Joey Kirkland
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Ulf Dittmer wrote:I gave it a quick test with the current Felix distribution. Here are a few observations:

  • Contrary to what the documentation says, I'm not being asked for a profile name. That doesn't seem to have any impact, though.


  • Note that issuing "install file:..." does install a bundle, but it does not start it. You need to do that manually by issuing "start N" (where N is the bundle ID as listed in the "lb" listing). Or you need to load the bundle by issuing "start file:..." which installs and starts in one step.


  • For Example1, I see the expected output when the bundle is started and stopped.


  • Example2 doesn't do anything by itself - it's just a service which you can test by installing and running Example3.


  • Other than the issue about not having to enter a "profile name", all three examples compile, run and install pretty much as described in the documentation.


  • Typing "lb" gives a handy overview of which bundles are installed, and which are running.


  • Hi, thanks again for your reply.

    I did try various combinations of start, install and so on - I never could get it to print to the screen. After this, I took a look at that kholperfish one, and it worked a little better, but still gave me problems. I'm now on Equinox and that seems to actually work for me, though I'm running into additional problems with that. Guess this framework has my number.

    But I'm glad to hear that the examples worked for you - it just must be something wrong I am doing that isn't easily tracked down. I'm going to stick with Equinox for now, since I can do some development with it. Your link was helpful - to the docs - I've already put it to use!
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Sorry to hear that Felix didn't work out for you, especially as I was able to download it, follow the instructions for the examples, and have it work. I suppose it could be that I've used it before and thus did something that wasn't explicitly mentioned in the instructions. Either way, you couldn't have been off by much. Felix has some nice features that make it worthwhile exploring IMO (such as the Karaf container, amongst others).
     
    Joey Kirkland
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Ulf Dittmer wrote:Sorry to hear that Felix didn't work out for you, especially as I was able to download it, follow the instructions for the examples, and have it work. I suppose it could be that I've used it before and thus did something that wasn't explicitly mentioned in the instructions. Either way, you couldn't have been off by much. Felix has some nice features that make it worthwhile exploring IMO (such as the Karaf container, amongst others).



    This could be the case - after I get more experience with OSGi, I think I'll go back and figure out what was going on. I've written a test prototype in Equinox to do what I want, so I think this will work. OSGi is quite cool after you figure it out, I can see the benefits of it for sure!

    Thanks for your help
     
    A day job? In an office? My worst nightmare! Comfort me tiny ad!
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic