You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Stefano Lenzi <ki...@interfree.it> on 2006/07/13 14:33:24 UTC

Running Felix within Eclipse

Hi All,
	is there anyone that use Eclipse and that's is able to run Felix within
Eclipse because I didn't remember when it stopped to be runnable inside
Eclipse with my configuration and I'm having problem to fix it.
	Actually I'm using even the Maven2 plugin for Eclipse.

Any idea?

Stefano "Kismet" Lenzi

Re: Running Felix within Eclipse

Posted by Clement Escoffier <cl...@gmail.com>.
Hello,

I publish a small tutorial explaining how running Felix inside Eclipse. 
This tutorial is available at :
http://plop-plop.net/ipojo/index.php?option=com_content&task=view&id=23&Itemid=37

Clement


Stefano Lenzi a écrit :
> Hi All,
> 	is there anyone that use Eclipse and that's is able to run Felix within
> Eclipse because I didn't remember when it stopped to be runnable inside
> Eclipse with my configuration and I'm having problem to fix it.
> 	Actually I'm using even the Maven2 plugin for Eclipse.
>
> Any idea?
>
> Stefano "Kismet" Lenzi
>
>   


Re: Running Felix within Eclipse

Posted by Dale Peakall <da...@peakall.com>.
> 	Also, I've a question there is a way to get maven create a eclipse
> project with all the bundle? Because I've tried "mvn eclipse:eclipse"
> from the trunk directory but with no success.

You need to have installed all the bundles (i.e. mvn install) prior to 
executing mvn eclipse:eclipse.


Re: Running Felix within Eclipse

Posted by Stefano Lenzi <ki...@interfree.it>.
Hi Clement,
	thanks for the tips, but doing that I found that even some source
artifacts of our project haven't been deployed yet.
	In fact I get a warning related to:
- org.apache.felix:org.osgi.core:0.8.0-SNAPSHOT
- org.apache.felix:org.apache.felix.framework:0.8.0-SNAPSHOT
- org.apache.felix:org.apache.felix.shell:0.8.0-SNAPSHOT

	Also, I've a question there is a way to get maven create a eclipse
project with all the bundle? Because I've tried "mvn eclipse:eclipse"
from the trunk directory but with no success.

Stefano "Kismet" Lenzi


Clement Escoffier wrote:
> Hi,
> 
> I run Felix inside Eclipse. It is very useful to debug bundles.
> 
> To do it, follow the following process :
>     - Get the Felix Trunk projects, and compile the trunk
>     - In the org.apache.felix.main subproject, launch mvn
> eclipse:eclipse (it create an eclipse project according to the pom.xml)
>    -  In Eclipse, add the variable M2_REPO (Window - Preference - Java -
> Build Path - Classpath Variable), this variable point inside your maven
> repository
>    - Import the project org.apache.felix.main (Import existing project
> in the workspace)
>    - Add the bin/felix.jar file inside the project build path.
>    - Create a run configuration :
>       - project = org.apache.felix.main
>       - Main class = org.apache.felix.main.Main
>       - check "include libraries when searching for a main class"
>       - in the arguments tabs, change the working directory to :
> ${workspace_loc:org.apache.felix.main}
>   - Save your configration and run it
> 
> When you launch this configuration in the debug mode, you will be able
> to debug your bundles.
> 
> Clement
> 

Re: Running Felix within Eclipse

Posted by Felix Cuadrado <fc...@dit.upm.es>.
On Friday 14 July 2006 14:43, Jeff McAffer wrote:
> I assume here that you are NOT using PDE in eclipse right?  That is, from
> the Eclipse perspective you are just developing Java code in Java
> projects.  It also seems that you are using maven to do the builds.  If
> this is correct, you should end up with a set of Maven created JARs
> wherever Maven put them.  From there all you should have to do is create a
> Java Launch Configuration and run.  Of course if you change the code in
> the workspace then you have to run Maven again and get new JARs generated.
>
> Not knowing Felix code at all but based on our Equinox experience I
> suspect the problem with Felix not picking up your new code is because
> Felix copies the JARs when you install the bundles.  I recall that Richard
> added the ability to intsall bundles by reference but don't know the
> details (I assume it works somewhat like the support in Equinox).  Perhaps
> you could use that for installing your bundles?  Note thta you may still
> have refresh problems when changing manifest information or anything else
> the Felix (or installed bundles) cache.
>
> BTW, in case people don't understand, this is exactly the sort of stuff
> that PDE is designed to take care of for you.  It does the classpath
> management, package visibility, building, cache management and framework
> launching.  Developers don't have to mess with classpaths, building, ...
> They just code and run.  It would be interesting to see how these
> facilities could be brought to bear on Felix.  For example, since there is
> no standard way of launching frameworks, PDE currently only launches
> Equinox.  Perhaps someone in the this community would be interested in
> contributing support for launching Felix?
>
> Jeff

My Master Thesis work was an Eclipse feature called eLuzien, which provides 
wizards, editors and launchers for developing OSGi bundles with Eclipse. The 
feature depends only on JDT, not PDE, as the work started last year in April, 
before we knew PDE was going to improve the support for developing bundles. 

eLuzien currently supports launching bundles in Equinox, Oscar2 and 
Knopflerfish2. Bundles can be added to the configuration either from jar 
files or from eLuzien projects (unfortunately not pde plug-in projects) and 
the launch configurations are generic with a parameter specifying the 
framework implementation to use (an extension point allows adding support for 
more frameworks). If someone wants to have a look you can go to:
http://eluzien.forge.os4os.org

As PDE now overlaps most of eLuzien's functionality and is not compatible with 
it there is no point at updating it, but I can have a look at PDE and see 
whether I can contribute to it support for launching Felix or other OSGi 
frameworks if there is interest in it. 

Félix




Re: Running Felix within Eclipse

Posted by Stefano Lenzi <ki...@interfree.it>.
Richard S. Hall wrote:
> Francesco Furfari wrote:
>>
>> I guess Stefano is referring to changing the code interactively 
>> without regenerated the Jar.
>> I'm still using a standard Java project without mvn plugin, in this 
>> configuration when I set a breakpoint, for example in the "switch 
>> on/off" action of the TV bundle, and during the debugging I save a 
>> modified version of the source code (without new types or any other 
>> heavy modification)  the debugger is able to reload the class  (I'm 
>> supposing) and update the execution flow immediately. Of course if you 
>> stop Felix and restart it again your changes are lost, but it's 
>> sufficient to save again the sources (e.g with a new blank space) to 
>> force again the reloading of the class.
>> All that installing the bundle in the standard way (not references ...)
> 
> I think this still works because Peter was showing me how to do some 
> debugging in Eclipse at ApacheCon and we did this exact thing. 
For me is not working anymore :-( I was able to do that with Oscar but 
it never worked with Eclipse for me :-(

> Although, 
> the way I set it was was to connect to a running VM...I did not run 
> Felix from Eclipse...but I don't think that would be much different that 
> if you created a launcher in Eclipse.
So if Peter knows will be nice if he can share how to do that :)

> 
> I don't really know.
> 
> Also, as another option, you can install exploded bundle directories by 
> reference too.
I'll give it a try and I let you know...
> 
> -> richard



Re: Running Felix within Eclipse

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Francesco Furfari wrote:
> Richard S. Hall wrote:
>> Stefano Lenzi wrote:
>>>> From there all you should have to do is create a Java Launch 
>>>> Configuration and run.  Of course if you change the code in the 
>>>> workspace then you have to run Maven again and get new JARs generated.
>>> That's what I want to avoid when I'm coding...
>>
>> I don't use Eclipse in this way, so I cannot really offer too much 
>> advice.
>>
>> You could install the JAR by reference, e.g., "install 
>> reference:file:/path/to/jar", but you could run into some issues if 
>> you majorly change the structure of your JAR file.
>
> I guess Stefano is referring to changing the code interactively 
> without regenerated the Jar.
> I'm still using a standard Java project without mvn plugin, in this 
> configuration when I set a breakpoint, for example in the "switch 
> on/off" action of the TV bundle, and during the debugging I save a 
> modified version of the source code (without new types or any other 
> heavy modification)  the debugger is able to reload the class  (I'm 
> supposing) and update the execution flow immediately. Of course if you 
> stop Felix and restart it again your changes are lost, but it's 
> sufficient to save again the sources (e.g with a new blank space) to 
> force again the reloading of the class.
> All that installing the bundle in the standard way (not references ...)

I think this still works because Peter was showing me how to do some 
debugging in Eclipse at ApacheCon and we did this exact thing. Although, 
the way I set it was was to connect to a running VM...I did not run 
Felix from Eclipse...but I don't think that would be much different that 
if you created a launcher in Eclipse.

I don't really know.

Also, as another option, you can install exploded bundle directories by 
reference too.

-> richard


Re: Running Felix within Eclipse

Posted by Francesco Furfari <fr...@isti.cnr.it>.

Richard S. Hall wrote:
> Stefano Lenzi wrote:
>>> From there all you should have to do is create a Java Launch 
>>> Configuration and run.  Of course if you change the code in the 
>>> workspace then you have to run Maven again and get new JARs generated.
>> That's what I want to avoid when I'm coding...
>
> I don't use Eclipse in this way, so I cannot really offer too much 
> advice.
>
> You could install the JAR by reference, e.g., "install 
> reference:file:/path/to/jar", but you could run into some issues if 
> you majorly change the structure of your JAR file.

I guess Stefano is referring to changing the code interactively without 
regenerated the Jar.
I'm still using a standard Java project without mvn plugin, in this 
configuration when I set a breakpoint, for example in the "switch 
on/off" action of the TV bundle, and during the debugging I save a 
modified version of the source code (without new types or any other 
heavy modification)  the debugger is able to reload the class  (I'm 
supposing) and update the execution flow immediately. Of course if you 
stop Felix and restart it again your changes are lost, but it's 
sufficient to save again the sources (e.g with a new blank space) to 
force again the reloading of the class.
All that installing the bundle in the standard way (not references ...)

francesco

>
>> I don't know what is changed inside the core of Felix, but at the 
>> time of Oscar I was able to lunch it as standard Java Application and 
>> the debug the code and also change code during at run-time with Eclipse
>
> I am not sure I understand exactly, but in Oscar, it should have never 
> automatically saw changes in the bundle JAR file unless you updated 
> it, which would also be true in Felix. Felix does add the install by 
> reference feature, but even this has its limitations...some of which 
> might be improvable.
>
> -> richard


Re: Running Felix within Eclipse

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Stefano Lenzi wrote:
>> From there all you should have to do is create a Java Launch 
>> Configuration and run.  Of course if you change the code in the 
>> workspace then you have to run Maven again and get new JARs generated.
> That's what I want to avoid when I'm coding...

I don't use Eclipse in this way, so I cannot really offer too much advice.

You could install the JAR by reference, e.g., "install 
reference:file:/path/to/jar", but you could run into some issues if you 
majorly change the structure of your JAR file.

> I don't know what is changed inside the core of Felix, but at the time 
> of Oscar I was able to lunch it as standard Java Application and the 
> debug the code and also change code during at run-time with Eclipse

I am not sure I understand exactly, but in Oscar, it should have never 
automatically saw changes in the bundle JAR file unless you updated it, 
which would also be true in Felix. Felix does add the install by 
reference feature, but even this has its limitations...some of which 
might be improvable.

-> richard

Re: Running Felix within Eclipse

Posted by Stefano Lenzi <ki...@interfree.it>.
Jeff McAffer wrote:
> I assume here that you are NOT using PDE in eclipse right?  
Yes that's  right

> That is, from 
> the Eclipse perspective you are just developing Java code in Java 
> projects.  It also seems that you are using maven to do the builds.  If 
> this is correct, you should end up with a set of Maven created JARs 
> wherever Maven put them.  
True I also use eclipse:eclipse goal to create the Eclipse project, from 
the POM root after the Clement's tips

> From there all you should have to do is create a 
> Java Launch Configuration and run.  Of course if you change the code in 
> the workspace then you have to run Maven again and get new JARs generated.
That's what I want to avoid when I'm coding...

> 
> Not knowing Felix code at all but based on our Equinox experience I 
> suspect the problem with Felix not picking up your new code is because 
> Felix copies the JARs when you install the bundles.  I recall that Richard 
> added the ability to intsall bundles by reference but don't know the 
> details (I assume it works somewhat like the support in Equinox).  Perhaps 
> you could use that for installing your bundles?  Note thta you may still 
> have refresh problems when changing manifest information or anything else 
> the Felix (or installed bundles) cache.
I don't know what is changed inside the core of Felix, but at the time 
of Oscar I was able to lunch it as standard Java Application and the 
debug the code and also change code during at run-time with Eclipse

> 
> BTW, in case people don't understand, this is exactly the sort of stuff 
> that PDE is designed to take care of for you.  It does the classpath 
> management, package visibility, building, cache management and framework 
> launching.  Developers don't have to mess with classpaths, building, ... 
> They just code and run.  It would be interesting to see how these 
> facilities could be brought to bear on Felix.  For example, since there is 
> no standard way of launching frameworks, PDE currently only launches 
> Equinox.  Perhaps someone in the this community would be interested in 
> contributing support for launching Felix?

I think that will be nice, but I hope that can be done even with 
standard Eclipse with only Java Perspective
> 
> Jeff
> 
> 
> 
> 
> Stefano Lenzi <ki...@interfree.it> 
> 07/14/2006 08:22 AM
> Please respond to
> felix-dev@incubator.apache.org
> 
> 
> To
> felix-dev@incubator.apache.org
> cc
> 
> Subject
> Re: Running Felix within Eclipse
> 
> 
> 
> 
> 
> 
>> Yes I had osgi.core in my classpath due to project dependencies of the 
>> project org.apache.felix.main to org.osgi.core so to get it working
>> had to:
>>  - go to run configuration
>>  - go to classpath
>>  - ensure that felix.jar is there( if you followed the instruction of 
>> Clement should be here) otherwise add it
>>  - move it up so that felix.jar become the first line under User Entries
>>
>> Now is working back ^_^
>>
>>
> 
> I was happy too early...  :-S
> Right now, I'm able to run Felix within Eclipse, but when I update the 
> source code of my bundle and then I start Felix, Felix do not notice the 
> difference(Felix continues to use the old binary code).
>                  So I end with a binary that is not synched with the 
> sources and also 
> without the update that I have made to it.
> 
>                  Any idea?
> 
> Stefano "Kismet" Lenzi
> 
> 


Re: Running Felix within Eclipse

Posted by Jeff McAffer <Je...@ca.ibm.com>.
I assume here that you are NOT using PDE in eclipse right?  That is, from 
the Eclipse perspective you are just developing Java code in Java 
projects.  It also seems that you are using maven to do the builds.  If 
this is correct, you should end up with a set of Maven created JARs 
wherever Maven put them.  From there all you should have to do is create a 
Java Launch Configuration and run.  Of course if you change the code in 
the workspace then you have to run Maven again and get new JARs generated.

Not knowing Felix code at all but based on our Equinox experience I 
suspect the problem with Felix not picking up your new code is because 
Felix copies the JARs when you install the bundles.  I recall that Richard 
added the ability to intsall bundles by reference but don't know the 
details (I assume it works somewhat like the support in Equinox).  Perhaps 
you could use that for installing your bundles?  Note thta you may still 
have refresh problems when changing manifest information or anything else 
the Felix (or installed bundles) cache.

BTW, in case people don't understand, this is exactly the sort of stuff 
that PDE is designed to take care of for you.  It does the classpath 
management, package visibility, building, cache management and framework 
launching.  Developers don't have to mess with classpaths, building, ... 
They just code and run.  It would be interesting to see how these 
facilities could be brought to bear on Felix.  For example, since there is 
no standard way of launching frameworks, PDE currently only launches 
Equinox.  Perhaps someone in the this community would be interested in 
contributing support for launching Felix?

Jeff




Stefano Lenzi <ki...@interfree.it> 
07/14/2006 08:22 AM
Please respond to
felix-dev@incubator.apache.org


To
felix-dev@incubator.apache.org
cc

Subject
Re: Running Felix within Eclipse






> 
> Yes I had osgi.core in my classpath due to project dependencies of the 
> project org.apache.felix.main to org.osgi.core so to get it working
> had to:
>  - go to run configuration
>  - go to classpath
>  - ensure that felix.jar is there( if you followed the instruction of 
> Clement should be here) otherwise add it
>  - move it up so that felix.jar become the first line under User Entries
> 
> Now is working back ^_^
> 
> 

I was happy too early...  :-S
Right now, I'm able to run Felix within Eclipse, but when I update the 
source code of my bundle and then I start Felix, Felix do not notice the 
difference(Felix continues to use the old binary code).
                 So I end with a binary that is not synched with the 
sources and also 
without the update that I have made to it.

                 Any idea?

Stefano "Kismet" Lenzi


Re: Running Felix within Eclipse

Posted by Stefano Lenzi <ki...@interfree.it>.
> 
> Yes I had osgi.core in my classpath due to project dependencies of the 
> project org.apache.felix.main to org.osgi.core so to get it working
> had to:
>  - go to run configuration
>  - go to classpath
>  - ensure that felix.jar is there( if you followed the instruction of 
> Clement should be here) otherwise add it
>  - move it up so that felix.jar become the first line under User Entries
> 
> Now is working back ^_^
> 
> 

I was happy too early...  :-S
Right now, I'm able to run Felix within Eclipse, but when I update the 
source code of my bundle and then I start Felix, Felix do not notice the 
difference(Felix continues to use the old binary code).
	So I end with a binary that is not synched with the sources and also 
without the update that I have made to it.

	Any idea?

Stefano "Kismet" Lenzi

Re: Running Felix within Eclipse

Posted by Stefano Lenzi <ki...@interfree.it>.
santillan wrote:
> Well, that happened to me, and it was because my classpath was using the
> AdminPermission class included in the osgi.core instead of the one tailored
> for Felix (and thus including the vendor property). However, that only
> happened when I run directly from sources, not when I run from the "mvn
> install"'ed felix.jar. Do you perchance have some osgi.core in the runtime
> classpath?

Yes I had osgi.core in my classpath due to project dependencies of the 
project org.apache.felix.main to org.osgi.core so to get it working
had to:
  - go to run configuration
  - go to classpath
  - ensure that felix.jar is there( if you followed the instruction of 
Clement should be here) otherwise add it
  - move it up so that felix.jar become the first line under User Entries

Now is working back ^_^

RE: Running Felix within Eclipse

Posted by santillan <sa...@dit.upm.es>.
Well, that happened to me, and it was because my classpath was using the
AdminPermission class included in the osgi.core instead of the one tailored
for Felix (and thus including the vendor property). However, that only
happened when I run directly from sources, not when I run from the "mvn
install"'ed felix.jar. Do you perchance have some osgi.core in the runtime
classpath?

--

Manuel Santillán <sa...@dit.upm.es>
http://www.dit.upm.es/santillan
Departamento de Ingeniería de Sistemas Telemáticos 
Escuela Técnica Superior de Ingenieros de Telecomunicación 
Universidad Politécnica de Madrid 
Avda. Complutense, s/n 
28040 Madrid SPAIN 
Tel. +34 913367366 ext.3034

-----Mensaje original-----
De: Stefano Lenzi [mailto:kismet@interfree.it] 
Enviado el: jueves, 13 de julio de 2006 17:18
Para: felix-dev@incubator.apache.org
Asunto: Re: Running Felix within Eclipse

Clement Escoffier wrote:
> Hi,
> 
> I run Felix inside Eclipse. It is very useful to debug bundles.
> 
> To do it, follow the following process :
>     - Get the Felix Trunk projects, and compile the trunk
>     - In the org.apache.felix.main subproject, launch mvn
> eclipse:eclipse (it create an eclipse project according to the pom.xml)
>    -  In Eclipse, add the variable M2_REPO (Window - Preference - Java -
> Build Path - Classpath Variable), this variable point inside your maven
> repository
>    - Import the project org.apache.felix.main (Import existing project
> in the workspace)
>    - Add the bin/felix.jar file inside the project build path.
>    - Create a run configuration :
>       - project = org.apache.felix.main
>       - Main class = org.apache.felix.main.Main
>       - check "include libraries when searching for a main class"
>       - in the arguments tabs, change the working directory to :
> ${workspace_loc:org.apache.felix.main}
>   - Save your configration and run it
> 
> When you launch this configuration in the debug mode, you will be able
> to debug your bundles.
> 

I'm able to get the "profile selection" of Felix, but then I got the
following error message:

Exception in thread "main" java.lang.NoClassDefFoundError:
org.osgi.vendor.framework property not set
	at
org.osgi.framework.AdminPermission$1.run(AdminPermission.java:148)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.osgi.framework.AdminPermission.<clinit>(AdminPermission.java:142)
	at org.apache.felix.framework.Felix.<clinit>(Felix.java:105)
	at org.apache.felix.main.Main.main(Main.java:189)



Re: Running Felix within Eclipse

Posted by Stefano Lenzi <ki...@interfree.it>.
Clement Escoffier wrote:
> Hi,
> 
> I run Felix inside Eclipse. It is very useful to debug bundles.
> 
> To do it, follow the following process :
>     - Get the Felix Trunk projects, and compile the trunk
>     - In the org.apache.felix.main subproject, launch mvn
> eclipse:eclipse (it create an eclipse project according to the pom.xml)
>    -  In Eclipse, add the variable M2_REPO (Window - Preference - Java -
> Build Path - Classpath Variable), this variable point inside your maven
> repository
>    - Import the project org.apache.felix.main (Import existing project
> in the workspace)
>    - Add the bin/felix.jar file inside the project build path.
>    - Create a run configuration :
>       - project = org.apache.felix.main
>       - Main class = org.apache.felix.main.Main
>       - check "include libraries when searching for a main class"
>       - in the arguments tabs, change the working directory to :
> ${workspace_loc:org.apache.felix.main}
>   - Save your configration and run it
> 
> When you launch this configuration in the debug mode, you will be able
> to debug your bundles.
> 

I'm able to get the "profile selection" of Felix, but then I got the
following error message:

Exception in thread "main" java.lang.NoClassDefFoundError:
org.osgi.vendor.framework property not set
	at org.osgi.framework.AdminPermission$1.run(AdminPermission.java:148)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.osgi.framework.AdminPermission.<clinit>(AdminPermission.java:142)
	at org.apache.felix.framework.Felix.<clinit>(Felix.java:105)
	at org.apache.felix.main.Main.main(Main.java:189)



Re: Running Felix within Eclipse

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

I run Felix inside Eclipse. It is very useful to debug bundles.

To do it, follow the following process :
     - Get the Felix Trunk projects, and compile the trunk
     - In the org.apache.felix.main subproject, launch mvn 
eclipse:eclipse (it create an eclipse project according to the pom.xml)
    -  In Eclipse, add the variable M2_REPO (Window - Preference - Java 
- Build Path - Classpath Variable), this variable point inside your 
maven repository
    - Import the project org.apache.felix.main (Import existing project 
in the workspace)
    - Add the bin/felix.jar file inside the project build path.
    - Create a run configuration :
       - project = org.apache.felix.main
       - Main class = org.apache.felix.main.Main
       - check "include libraries when searching for a main class"
       - in the arguments tabs, change the working directory to : 
${workspace_loc:org.apache.felix.main}
   - Save your configration and run it

When you launch this configuration in the debug mode, you will be able 
to debug your bundles.

Clement

Stefano Lenzi a écrit :
> Hi All,
> 	is there anyone that use Eclipse and that's is able to run Felix within
> Eclipse because I didn't remember when it stopped to be runnable inside
> Eclipse with my configuration and I'm having problem to fix it.
> 	Actually I'm using even the Maven2 plugin for Eclipse.
>
> Any idea?
>
> Stefano "Kismet" Lenzi
>
>