This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Apache Felix Tutorials Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Apache Felix Tutorials" Watch "Apache Felix Tutorials" New topic
Author

Apache Felix Tutorials

Joey Kirkland
Greenhorn

Joined: Jan 22, 2013
Posts: 5
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!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
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.


Ping & DNS - my free Android networking tools app
Joey Kirkland
Greenhorn

Joined: Jan 22, 2013
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
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

    Joined: Jan 22, 2013
    Posts: 5
    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
    Marshal

    Joined: Mar 22, 2005
    Posts: 41155
        
      45
    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

    Joined: Jan 22, 2013
    Posts: 5
    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
     
     
    subject: Apache Felix Tutorials
     
    Similar Threads
    problem in glassfish
    OSGI working example
    osgi (felix): NoClassDefFoundError: org/apache/commons/logging/LogFactory
    Install 3rd party jars
    Best OSGI free impl? Java Modules vs. OSGi?