You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Mohica Jasha <mo...@gmail.com> on 2012/01/10 21:47:28 UTC

Felix DependencyManager with annotation/eclipse

Hi,

1. I am trying to control the dependencies of a bundle using felix
annotations as explained here:
http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
If I build the jar file out of the example and through it into felix
launcher, it works perfectly, However I would like to debug the bundle
within eclipse, and I cannot launch the bundle.

I tried so many ways but no luck. Any idea how I can debug the bundle
within eclipse?

2. I slightly changed the pom file to include the osgi.bnd file and the
"-plugin
org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn" line
in the bnd file causes the following compilation error when I build the
project/package using maven:

[WARNING] Warning building bundle
mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions in
Private-Package, or -testpackages that are never used:
mypackage\.dm\.testan\.testan
Classpath:
Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0

[WARNING] Warning building bundle
mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
[ERROR] Error building bundle
mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem loading the
plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
exception: (java.lang.NoClassDefFoundError:
org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not found,
parent:  org.codehaus.classworlds.RealmClassLoader@585976c2 urls:[]
exception:java.lang.ClassNotFoundException:
org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
[ERROR] Error(s) found in bundle configuration
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error(s) found in bundle configuration

Thanks,
Mohica

Re: Felix DependencyManager with annotation/eclipse

Posted by Mohica Jasha <mo...@gmail.com>.
Hi Pierre,

Yes, your proposal helps. I will open a jira issue.
Thank you very much for your help.

Best,
Mohica

On Sat, Feb 4, 2012 at 4:42 AM, Pierre De Rop <pi...@gmail.com>wrote:

> Hi Mohica,
>
> Are you still interested by the proposal I made in previous post ?
> I would like to be sure you are still interested before implementing it.
> (if yes, then please open a jira issue so I can start the work).
>
> But may be you have found another work around ?
> let me know, thanks;
>
> kind regards;
> /Pierre
>
> On Mon, Jan 23, 2012 at 9:58 AM, Pierre De Rop <pierre.derop@gmail.com
> >wrote:
>
> > Hi Mohica,
> >
> > Currently, the dependencymanager annotation plugin is only able to
> > generate the descriptor files (META-INF/dependencymanager/*) in the
> target
> > bundle, not in the maven project directory (that is: under
> > com.myannotation.project/com.
> > myannotation.testbundle/META-INF/).
> >
> > So, it seems that karaf/eik (or equinox ?) is not using the target bundle
> > when launching/debugging the bundle, but is instead internally
> > reconstructing the bundle from the eclipse project ? (something similar
> to
> > "exploded" karaf bundles ?)
> >
> > Anyway, if it is helpful to you, I propose the following: I can add a new
> > optional parameter (<generated-output-dir>) in the dependencymanager
> > annotation maven plugin, in order to let you specify a path (starting
> from
> > the project base directory), and the maven plugin will then generate the
> > extra descriptors files in that path.
> >
> > For instance, in the following, the optional <generated-output-dir>
> > parameter is set to ".", and allows to generate the descriptors
> > (META-INF/*) in the root project directory (in
> > com.myannotation.project/com.myannotation.testbundle/):
> >
> >             <plugin>
> >                 <groupId>org.apache.felix</groupId>
> >
> > <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
> >                 <version>3.1.0-SNAPSHOT</version>
> >                 <executions>
> >                     <execution>
> >                         <goals>
> >                             <goal>scan</goal>
> >                         </goals>
> >                         <configuration>
> >                             <log>warn</log>
> >
> <generated-output-dir>.</generated-output-dir>
> >                         </configuration>
> >                     </execution>
> >                 </executions>
> >             </plugin>
> >
> >
> > But this will only be possible if you use the maven-plugin, and not the
> > bnd plugin, in osgi.bnd.
> > If you are OK with the above proposal, then please open a change request
> > jira issue for dependencymanager, and I will commit a candidate patch.
> >
> > PS: I tried to install karaf/eik, like you suggested but could not
> > reproduce the issue (probably because I'm not enough experienced with pde
> > plugins and with eik/karaf), so may be you should describe the exacts
> steps
> > in the jira issue in order to let me quickly validate the patch before
> > committing).
> >
> > kind regards;
> > /pierre
> >
> > On Wed, Jan 18, 2012 at 7:12 PM, Mohica Jasha <mohica.jasha@gmail.com
> >wrote:
> >
> >> Hi Pierre,
> >>
> >> Sorry for my late response.
> >>
> >
> >> How I debug in Eclipse:
> >>
> >> I am using http://karaf.apache.org/ as my target platform and
> >> http://code.google.com/a/eclipselabs.org/p/eik/ plugin which integrates
> >> karaf with eclipse for debugging.
> >> The way it works is that: I don't need to deploy the generated jar files
> >> manually, but eclipse launches my existing Plug-in Project within the
> Karaf
> >> OSGi-Framework.
> >>
> >> I am not sure but I think the above method is under the "Using Pax
> >> Cursor to launch easily any supported OSGi framework inside Eclipse."
> >> category in the link you sent,
> >> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
> >>
> >>
> >>
> >> As I mentioned in the previous email, the jar file generated using "mvn
> >> package" is flawless. The jar file HAS the META-INF/dependencymanager
> >> sub-directory.
> >>
> >> I have attached my project source code. After unzipping it you can
> simply
> >> execute the following command to build it:
> >> mvn clean package eclipse:eclipse -Declipse.pde install
> >>
> >> The problem is eclipse needs META-INF/dependencymanager/ not only in the
> >> jar file but also in the project folder hierarchy, i.e.,
> >> com.myannotation.project/com.myannotation.testbundle/META-INF
> >>
> >> After executing the mvn command the generated jar file has the
> >> META-INF/dependencymanager/ subdirectory. But there is no
> dependencymanager
> >> sub-directory inside the
> >> com.myannotation.project/com.myannotation.testbundle/META-INF . So I
> cannot
> >> debug from eclipse. If I manually copy dependencymanager from the jar
> file
> >> to com.myannotation.project/com.myannotation.testbundle/META-INF/, then
> >> debugging within eclipse will start to work.
> >>
> >> My Question:
> >> What modification should I make to my pom files to put dependencymanager
> >> not only in the jar file but also in the project folder hierarchy, i.e.,
> >> com.myannotation.project/com.myannotation.testbundle/META-INF/ ?
> >>
> >> Thanks,
> >> Mohica
> >>
> >>
> >>
> >>
> >> On Thu, Jan 12, 2012 at 10:42 AM, Pierre De Rop <pierre.derop@gmail.com
> >wrote:
> >>
> >>> Hi Mohica,
> >>>
> >>> Good to know that you found how to debug using eclipse, may be you have
> >>> read the following link ?
> >>>
> >>> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
> >>>
> >>> Now, I have tried to reproduce the issue you are describing, but I
> can't.
> >>> When you change the annotation in the source file, you indeed have to
> >>> recompile the project, by typing mvn package, or mvn install, and the
> >>> descriptors are automatically generated and stored in the target
> bundle,
> >>> under META-INF/dependencymanager/ subdirectory.
> >>>
> >>> The question is, how are you debugging ? Are you doing something
> similar
> >>> to
> >>> what is described in the above link ?
> >>>
> >>> /Pierre
> >>>
> >>> On Wed, Jan 11, 2012 at 6:31 PM, Mohica Jasha <mohica.jasha@gmail.com
> >>> >wrote:
> >>>
> >>> > Hi Pierre,
> >>> >
> >>> > The pom file works for me. Thank you.
> >>> >
> >>> > I found out how to debug the code in in eclipse:
> >>> >
> >>> > When I build the package using maven the maven put an annotation
> >>> metadata
> >>> > file into the generated jar file in the target folder:
> >>> >
> >>> >
> >>>
> org.apache.felix.dependencymanager.samples.annotation.hello.jar:META-INF/dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
> >>> >
> >>> > The content of the file is the following:
> >>> >
> >>> >
> >>>
> {"impl":"org.apache.felix.dependencymanager.samples.annotation.hello","start":"activate","type":"Component"}
> >>> >
> >>> > But it doesn't add
> >>> >
> >>> >
> >>>
> dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
> >>> > into the META-INF folder of the project. (I don't know why though?!)
> >>> > If I manually copy the above file from the jar file into the
> >>> > META-INF/dependencymanager/ folder of the project, then the
> >>> corresponding
> >>> > service starts and eclipse can debug it.
> >>> >
> >>> > **A new Question**:
> >>> > Everytime I modify the annotation in a source file I have to run the
> >>> "mvn
> >>> > package" to create the target jar file and then copy the contents of
> >>> > META-INF/dependencymanager/* form the jar file into the
> >>> > META-INF/dependencymanager/ folder in the project. Is there a way to
> >>> make
> >>> > it automatic?
> >>> >
> >>> > Thanks,
> >>> > Mohica
> >>> >
> >>> >
> >>> >
> >>> > On Wed, Jan 11, 2012 at 5:55 AM, Pierre De Rop <
> pierre.derop@gmail.com
> >>> > >wrote:
> >>> >
> >>> > > Hello Mohica;
> >>> > >
> >>> > > Regarding your second question,
> >>> > >
> >>> > > if I understand correctly, you are trying to use an osgi bnd
> >>> directive
> >>> > file
> >>> > > from maven, right ? Since the DM annotation API also contains a
> >>> native
> >>> > bnd
> >>> > > plugin, then it is indeed possible to do this, and I think that the
> >>> root
> >>> > > cause of the NoClassDefFoundError is that you don't have added a
> >>> > dependency
> >>> > > over the DM annotation plugin inside the maven-bundle-plugin, and
> >>> when
> >>> > bnd
> >>> > > tries to load the DM plugin (thanks to the -plugin option), then it
> >>> does
> >>> > > not find it because the dependency over
> >>> > > org.apache.felix.dependencymanager.annotation bundle is missing
> >>> within
> >>> > the
> >>> > > maven-bundle-plugin.
> >>> > >
> >>> > > I have tried the following which works fine for me (I don't use a
> >>> > separate
> >>> > > osgi.bnd file but I rather declare the "_plugin" option in the
> >>> > > maven-bundle-plugin pom xml element, but I think it's similar to
> >>> that you
> >>> > > are doing). Notice that:
> >>> > >    - I use "_plugin" option from the maven-bundle-plugin instead of
> >>> > > "-plugin" bnd directive.
> >>> > >    - And since the DM annotation bnd plugin is invoked directly
> >>> using the
> >>> > > _plugin option, then it is not needed anymore to
> >>> > > declare the DM maven bundle plugin, which is useless in this case.
> >>> > >
> >>> > > Here it is:
> >>> > >
> >>> > >    <build>
> >>> > >        <plugins>
> >>> > >            <plugin>
> >>> > >                <groupId>org.apache.maven.plugins</groupId>
> >>> > >                <artifactId>maven-compiler-plugin</artifactId>
> >>> > >                <configuration>
> >>> > >                    <source>1.5</source>
> >>> > >                    <target>1.5</target>
> >>> > >                </configuration>
> >>> > >            </plugin>
> >>> > >            <plugin>
> >>> > >                <groupId>org.apache.felix</groupId>
> >>> > >                <artifactId>maven-bundle-plugin</artifactId>
> >>> > >                <version>2.3.4</version>
> >>> > >                <extensions>true</extensions>
> >>> > >                <configuration>
> >>> > >                    <instructions>
> >>> > >                        <Bundle-Name>Apache Felix Dependency Manager
> >>> > > Annotation Sample</Bundle-Name>
> >>> > >
> >>> > >
> >>> > >
> >>> >
> >>>
> <Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>
> >>> > >
> >>> > >
> >>> > >
> >>> >
> >>>
> <Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>
> >>> > >
> >>> > >
> >>>
> <Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
> >>> > >                        <!-- Ask bnd to load/run our dependency
> >>> manager
> >>> > bnd
> >>> > > annotation plugin -->
> >>> > >
> >>> > >
> >>> > >
> >>> >
> >>>
> <_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
> >>> > >                    </instructions>
> >>> > >                </configuration>
> >>> > >                <dependencies>
> >>> > >                   <dependency>
> >>> > >                      <!-- Add our DM annotation plugin in bndlib
> >>> class
> >>> > > path, allowing bnd to be
> >>> > >                             able to instantiate our DM plugin ...
> -->
> >>> > >                      <groupId>${pom.groupId}</groupId>
> >>> > >
> >>> > >
> >>> <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
> >>> > >                      <version>3.0.0</version>
> >>> > >                   </dependency>
> >>> > >                 </dependencies>
> >>> > >            </plugin>
> >>> > >        </plugins>
> >>> > >    </build>
> >>> > >
> >>> > > Regarding your first question, I will get back to you later
> >>> (tomorrow if
> >>> > > possible).
> >>> > >
> >>> > > Hope this helps;
> >>> > > BR
> >>> > > /Pierre
> >>> > >
> >>> > > On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <
> >>> mohica.jasha@gmail.com
> >>> > > >wrote:
> >>> > >
> >>> > > > Hi,
> >>> > > >
> >>> > > > 1. I am trying to control the dependencies of a bundle using
> felix
> >>> > > > annotations as explained here:
> >>> > > >
> >>> > > >
> >>> > >
> >>> >
> >>>
> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
> >>> > > > If I build the jar file out of the example and through it into
> >>> felix
> >>> > > > launcher, it works perfectly, However I would like to debug the
> >>> bundle
> >>> > > > within eclipse, and I cannot launch the bundle.
> >>> > > >
> >>> > > > I tried so many ways but no luck. Any idea how I can debug the
> >>> bundle
> >>> > > > within eclipse?
> >>> > > >
> >>> > > > 2. I slightly changed the pom file to include the osgi.bnd file
> >>> and the
> >>> > > > "-plugin
> >>> > > >
> >>> org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn"
> >>> > line
> >>> > > > in the bnd file causes the following compilation error when I
> >>> build the
> >>> > > > project/package using maven:
> >>> > > >
> >>> > > > [WARNING] Warning building bundle
> >>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions
> >>> in
> >>> > > > Private-Package, or -testpackages that are never used:
> >>> > > > mypackage\.dm\.testan\.testan
> >>> > > > Classpath:
> >>> > > >
> >>> > > >
> >>> > >
> >>> >
> >>>
> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
> >>> > > >
> >>> > > > [WARNING] Warning building bundle
> >>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR
> or
> >>> > > > directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
> >>> > > > [ERROR] Error building bundle
> >>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem
> >>> loading
> >>> > the
> >>> > > > plugin:
> org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
> >>> > > > exception: (java.lang.NoClassDefFoundError:
> >>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not
> >>> found,
> >>> > > > parent:  org.codehaus.classworlds.RealmClassLoader@585976c2urls
> :[]
> >>> > > > exception:java.lang.ClassNotFoundException:
> >>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
> >>> > > > [ERROR] Error(s) found in bundle configuration
> >>> > > > [INFO]
> >>> > > >
> >>> >
> >>>
> ------------------------------------------------------------------------
> >>> > > > [ERROR] BUILD ERROR
> >>> > > > [INFO]
> >>> > > >
> >>> >
> >>>
> ------------------------------------------------------------------------
> >>> > > > [INFO] Error(s) found in bundle configuration
> >>> > > >
> >>> > > > Thanks,
> >>> > > > Mohica
> >>> > > >
> >>> > >
> >>> >
> >>>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >> For additional commands, e-mail: users-help@felix.apache.org
> >>
> >
> >
>

Re: Felix DependencyManager with annotation/eclipse

Posted by Pierre De Rop <pi...@gmail.com>.
Hi Mohica,

Are you still interested by the proposal I made in previous post ?
I would like to be sure you are still interested before implementing it.
(if yes, then please open a jira issue so I can start the work).

But may be you have found another work around ?
let me know, thanks;

kind regards;
/Pierre

On Mon, Jan 23, 2012 at 9:58 AM, Pierre De Rop <pi...@gmail.com>wrote:

> Hi Mohica,
>
> Currently, the dependencymanager annotation plugin is only able to
> generate the descriptor files (META-INF/dependencymanager/*) in the target
> bundle, not in the maven project directory (that is: under
> com.myannotation.project/com.
> myannotation.testbundle/META-INF/).
>
> So, it seems that karaf/eik (or equinox ?) is not using the target bundle
> when launching/debugging the bundle, but is instead internally
> reconstructing the bundle from the eclipse project ? (something similar to
> "exploded" karaf bundles ?)
>
> Anyway, if it is helpful to you, I propose the following: I can add a new
> optional parameter (<generated-output-dir>) in the dependencymanager
> annotation maven plugin, in order to let you specify a path (starting from
> the project base directory), and the maven plugin will then generate the
> extra descriptors files in that path.
>
> For instance, in the following, the optional <generated-output-dir>
> parameter is set to ".", and allows to generate the descriptors
> (META-INF/*) in the root project directory (in
> com.myannotation.project/com.myannotation.testbundle/):
>
>             <plugin>
>                 <groupId>org.apache.felix</groupId>
>
> <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
>                 <version>3.1.0-SNAPSHOT</version>
>                 <executions>
>                     <execution>
>                         <goals>
>                             <goal>scan</goal>
>                         </goals>
>                         <configuration>
>                             <log>warn</log>
>                             <generated-output-dir>.</generated-output-dir>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>
>
> But this will only be possible if you use the maven-plugin, and not the
> bnd plugin, in osgi.bnd.
> If you are OK with the above proposal, then please open a change request
> jira issue for dependencymanager, and I will commit a candidate patch.
>
> PS: I tried to install karaf/eik, like you suggested but could not
> reproduce the issue (probably because I'm not enough experienced with pde
> plugins and with eik/karaf), so may be you should describe the exacts steps
> in the jira issue in order to let me quickly validate the patch before
> committing).
>
> kind regards;
> /pierre
>
> On Wed, Jan 18, 2012 at 7:12 PM, Mohica Jasha <mo...@gmail.com>wrote:
>
>> Hi Pierre,
>>
>> Sorry for my late response.
>>
>
>> How I debug in Eclipse:
>>
>> I am using http://karaf.apache.org/ as my target platform and
>> http://code.google.com/a/eclipselabs.org/p/eik/ plugin which integrates
>> karaf with eclipse for debugging.
>> The way it works is that: I don't need to deploy the generated jar files
>> manually, but eclipse launches my existing Plug-in Project within the Karaf
>> OSGi-Framework.
>>
>> I am not sure but I think the above method is under the "Using Pax
>> Cursor to launch easily any supported OSGi framework inside Eclipse."
>> category in the link you sent,
>> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
>>
>>
>>
>> As I mentioned in the previous email, the jar file generated using "mvn
>> package" is flawless. The jar file HAS the META-INF/dependencymanager
>> sub-directory.
>>
>> I have attached my project source code. After unzipping it you can simply
>> execute the following command to build it:
>> mvn clean package eclipse:eclipse -Declipse.pde install
>>
>> The problem is eclipse needs META-INF/dependencymanager/ not only in the
>> jar file but also in the project folder hierarchy, i.e.,
>> com.myannotation.project/com.myannotation.testbundle/META-INF
>>
>> After executing the mvn command the generated jar file has the
>> META-INF/dependencymanager/ subdirectory. But there is no dependencymanager
>> sub-directory inside the
>> com.myannotation.project/com.myannotation.testbundle/META-INF . So I cannot
>> debug from eclipse. If I manually copy dependencymanager from the jar file
>> to com.myannotation.project/com.myannotation.testbundle/META-INF/, then
>> debugging within eclipse will start to work.
>>
>> My Question:
>> What modification should I make to my pom files to put dependencymanager
>> not only in the jar file but also in the project folder hierarchy, i.e.,
>> com.myannotation.project/com.myannotation.testbundle/META-INF/ ?
>>
>> Thanks,
>> Mohica
>>
>>
>>
>>
>> On Thu, Jan 12, 2012 at 10:42 AM, Pierre De Rop <pi...@gmail.com>wrote:
>>
>>> Hi Mohica,
>>>
>>> Good to know that you found how to debug using eclipse, may be you have
>>> read the following link ?
>>>
>>> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
>>>
>>> Now, I have tried to reproduce the issue you are describing, but I can't.
>>> When you change the annotation in the source file, you indeed have to
>>> recompile the project, by typing mvn package, or mvn install, and the
>>> descriptors are automatically generated and stored in the target bundle,
>>> under META-INF/dependencymanager/ subdirectory.
>>>
>>> The question is, how are you debugging ? Are you doing something similar
>>> to
>>> what is described in the above link ?
>>>
>>> /Pierre
>>>
>>> On Wed, Jan 11, 2012 at 6:31 PM, Mohica Jasha <mohica.jasha@gmail.com
>>> >wrote:
>>>
>>> > Hi Pierre,
>>> >
>>> > The pom file works for me. Thank you.
>>> >
>>> > I found out how to debug the code in in eclipse:
>>> >
>>> > When I build the package using maven the maven put an annotation
>>> metadata
>>> > file into the generated jar file in the target folder:
>>> >
>>> >
>>> org.apache.felix.dependencymanager.samples.annotation.hello.jar:META-INF/dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
>>> >
>>> > The content of the file is the following:
>>> >
>>> >
>>> {"impl":"org.apache.felix.dependencymanager.samples.annotation.hello","start":"activate","type":"Component"}
>>> >
>>> > But it doesn't add
>>> >
>>> >
>>> dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
>>> > into the META-INF folder of the project. (I don't know why though?!)
>>> > If I manually copy the above file from the jar file into the
>>> > META-INF/dependencymanager/ folder of the project, then the
>>> corresponding
>>> > service starts and eclipse can debug it.
>>> >
>>> > **A new Question**:
>>> > Everytime I modify the annotation in a source file I have to run the
>>> "mvn
>>> > package" to create the target jar file and then copy the contents of
>>> > META-INF/dependencymanager/* form the jar file into the
>>> > META-INF/dependencymanager/ folder in the project. Is there a way to
>>> make
>>> > it automatic?
>>> >
>>> > Thanks,
>>> > Mohica
>>> >
>>> >
>>> >
>>> > On Wed, Jan 11, 2012 at 5:55 AM, Pierre De Rop <pierre.derop@gmail.com
>>> > >wrote:
>>> >
>>> > > Hello Mohica;
>>> > >
>>> > > Regarding your second question,
>>> > >
>>> > > if I understand correctly, you are trying to use an osgi bnd
>>> directive
>>> > file
>>> > > from maven, right ? Since the DM annotation API also contains a
>>> native
>>> > bnd
>>> > > plugin, then it is indeed possible to do this, and I think that the
>>> root
>>> > > cause of the NoClassDefFoundError is that you don't have added a
>>> > dependency
>>> > > over the DM annotation plugin inside the maven-bundle-plugin, and
>>> when
>>> > bnd
>>> > > tries to load the DM plugin (thanks to the -plugin option), then it
>>> does
>>> > > not find it because the dependency over
>>> > > org.apache.felix.dependencymanager.annotation bundle is missing
>>> within
>>> > the
>>> > > maven-bundle-plugin.
>>> > >
>>> > > I have tried the following which works fine for me (I don't use a
>>> > separate
>>> > > osgi.bnd file but I rather declare the "_plugin" option in the
>>> > > maven-bundle-plugin pom xml element, but I think it's similar to
>>> that you
>>> > > are doing). Notice that:
>>> > >    - I use "_plugin" option from the maven-bundle-plugin instead of
>>> > > "-plugin" bnd directive.
>>> > >    - And since the DM annotation bnd plugin is invoked directly
>>> using the
>>> > > _plugin option, then it is not needed anymore to
>>> > > declare the DM maven bundle plugin, which is useless in this case.
>>> > >
>>> > > Here it is:
>>> > >
>>> > >    <build>
>>> > >        <plugins>
>>> > >            <plugin>
>>> > >                <groupId>org.apache.maven.plugins</groupId>
>>> > >                <artifactId>maven-compiler-plugin</artifactId>
>>> > >                <configuration>
>>> > >                    <source>1.5</source>
>>> > >                    <target>1.5</target>
>>> > >                </configuration>
>>> > >            </plugin>
>>> > >            <plugin>
>>> > >                <groupId>org.apache.felix</groupId>
>>> > >                <artifactId>maven-bundle-plugin</artifactId>
>>> > >                <version>2.3.4</version>
>>> > >                <extensions>true</extensions>
>>> > >                <configuration>
>>> > >                    <instructions>
>>> > >                        <Bundle-Name>Apache Felix Dependency Manager
>>> > > Annotation Sample</Bundle-Name>
>>> > >
>>> > >
>>> > >
>>> >
>>> <Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>
>>> > >
>>> > >
>>> > >
>>> >
>>> <Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>
>>> > >
>>> > >
>>> <Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
>>> > >                        <!-- Ask bnd to load/run our dependency
>>> manager
>>> > bnd
>>> > > annotation plugin -->
>>> > >
>>> > >
>>> > >
>>> >
>>> <_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
>>> > >                    </instructions>
>>> > >                </configuration>
>>> > >                <dependencies>
>>> > >                   <dependency>
>>> > >                      <!-- Add our DM annotation plugin in bndlib
>>> class
>>> > > path, allowing bnd to be
>>> > >                             able to instantiate our DM plugin ... -->
>>> > >                      <groupId>${pom.groupId}</groupId>
>>> > >
>>> > >
>>> <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
>>> > >                      <version>3.0.0</version>
>>> > >                   </dependency>
>>> > >                 </dependencies>
>>> > >            </plugin>
>>> > >        </plugins>
>>> > >    </build>
>>> > >
>>> > > Regarding your first question, I will get back to you later
>>> (tomorrow if
>>> > > possible).
>>> > >
>>> > > Hope this helps;
>>> > > BR
>>> > > /Pierre
>>> > >
>>> > > On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <
>>> mohica.jasha@gmail.com
>>> > > >wrote:
>>> > >
>>> > > > Hi,
>>> > > >
>>> > > > 1. I am trying to control the dependencies of a bundle using felix
>>> > > > annotations as explained here:
>>> > > >
>>> > > >
>>> > >
>>> >
>>> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
>>> > > > If I build the jar file out of the example and through it into
>>> felix
>>> > > > launcher, it works perfectly, However I would like to debug the
>>> bundle
>>> > > > within eclipse, and I cannot launch the bundle.
>>> > > >
>>> > > > I tried so many ways but no luck. Any idea how I can debug the
>>> bundle
>>> > > > within eclipse?
>>> > > >
>>> > > > 2. I slightly changed the pom file to include the osgi.bnd file
>>> and the
>>> > > > "-plugin
>>> > > >
>>> org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn"
>>> > line
>>> > > > in the bnd file causes the following compilation error when I
>>> build the
>>> > > > project/package using maven:
>>> > > >
>>> > > > [WARNING] Warning building bundle
>>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions
>>> in
>>> > > > Private-Package, or -testpackages that are never used:
>>> > > > mypackage\.dm\.testan\.testan
>>> > > > Classpath:
>>> > > >
>>> > > >
>>> > >
>>> >
>>> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
>>> > > >
>>> > > > [WARNING] Warning building bundle
>>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
>>> > > > directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
>>> > > > [ERROR] Error building bundle
>>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem
>>> loading
>>> > the
>>> > > > plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
>>> > > > exception: (java.lang.NoClassDefFoundError:
>>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not
>>> found,
>>> > > > parent:  org.codehaus.classworlds.RealmClassLoader@585976c2urls:[]
>>> > > > exception:java.lang.ClassNotFoundException:
>>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
>>> > > > [ERROR] Error(s) found in bundle configuration
>>> > > > [INFO]
>>> > > >
>>> >
>>> ------------------------------------------------------------------------
>>> > > > [ERROR] BUILD ERROR
>>> > > > [INFO]
>>> > > >
>>> >
>>> ------------------------------------------------------------------------
>>> > > > [INFO] Error(s) found in bundle configuration
>>> > > >
>>> > > > Thanks,
>>> > > > Mohica
>>> > > >
>>> > >
>>> >
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
>

Re: Felix DependencyManager with annotation/eclipse

Posted by Pierre De Rop <pi...@gmail.com>.
Hi Mohica,

Currently, the dependencymanager annotation plugin is only able to generate
the descriptor files (META-INF/dependencymanager/*) in the target bundle,
not in the maven project directory (that is: under
com.myannotation.project/com.
myannotation.testbundle/META-INF/).

So, it seems that karaf/eik (or equinox ?) is not using the target bundle
when launching/debugging the bundle, but is instead internally
reconstructing the bundle from the eclipse project ? (something similar to
"exploded" karaf bundles ?)

Anyway, if it is helpful to you, I propose the following: I can add a new
optional parameter (<generated-output-dir>) in the dependencymanager
annotation maven plugin, in order to let you specify a path (starting from
the project base directory), and the maven plugin will then generate the
extra descriptors files in that path.

For instance, in the following, the optional <generated-output-dir>
parameter is set to ".", and allows to generate the descriptors
(META-INF/*) in the root project directory (in
com.myannotation.project/com.myannotation.testbundle/):

            <plugin>
                <groupId>org.apache.felix</groupId>

<artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
                <version>3.1.0-SNAPSHOT</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>scan</goal>
                        </goals>
                        <configuration>
                            <log>warn</log>
                            <generated-output-dir>.</generated-output-dir>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


But this will only be possible if you use the maven-plugin, and not the bnd
plugin, in osgi.bnd.
If you are OK with the above proposal, then please open a change request
jira issue for dependencymanager, and I will commit a candidate patch.

PS: I tried to install karaf/eik, like you suggested but could not
reproduce the issue (probably because I'm not enough experienced with pde
plugins and with eik/karaf), so may be you should describe the exacts steps
in the jira issue in order to let me quickly validate the patch before
committing).

kind regards;
/pierre

On Wed, Jan 18, 2012 at 7:12 PM, Mohica Jasha <mo...@gmail.com>wrote:

> Hi Pierre,
>
> Sorry for my late response.
>

> How I debug in Eclipse:
>
> I am using http://karaf.apache.org/ as my target platform and
> http://code.google.com/a/eclipselabs.org/p/eik/ plugin which integrates
> karaf with eclipse for debugging.
> The way it works is that: I don't need to deploy the generated jar files
> manually, but eclipse launches my existing Plug-in Project within the Karaf
> OSGi-Framework.
>
> I am not sure but I think the above method is under the "Using Pax Cursor
> to launch easily any supported OSGi framework inside Eclipse." category
> in the link you sent,
> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
>
>
>
> As I mentioned in the previous email, the jar file generated using "mvn
> package" is flawless. The jar file HAS the META-INF/dependencymanager
> sub-directory.
>
> I have attached my project source code. After unzipping it you can simply
> execute the following command to build it:
> mvn clean package eclipse:eclipse -Declipse.pde install
>
> The problem is eclipse needs META-INF/dependencymanager/ not only in the
> jar file but also in the project folder hierarchy, i.e.,
> com.myannotation.project/com.myannotation.testbundle/META-INF
>
> After executing the mvn command the generated jar file has the
> META-INF/dependencymanager/ subdirectory. But there is no dependencymanager
> sub-directory inside the
> com.myannotation.project/com.myannotation.testbundle/META-INF . So I cannot
> debug from eclipse. If I manually copy dependencymanager from the jar file
> to com.myannotation.project/com.myannotation.testbundle/META-INF/, then
> debugging within eclipse will start to work.
>
> My Question:
> What modification should I make to my pom files to put dependencymanager
> not only in the jar file but also in the project folder hierarchy, i.e.,
> com.myannotation.project/com.myannotation.testbundle/META-INF/ ?
>
> Thanks,
> Mohica
>
>
>
>
> On Thu, Jan 12, 2012 at 10:42 AM, Pierre De Rop <pi...@gmail.com>wrote:
>
>> Hi Mohica,
>>
>> Good to know that you found how to debug using eclipse, may be you have
>> read the following link ?
>>
>> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
>>
>> Now, I have tried to reproduce the issue you are describing, but I can't.
>> When you change the annotation in the source file, you indeed have to
>> recompile the project, by typing mvn package, or mvn install, and the
>> descriptors are automatically generated and stored in the target bundle,
>> under META-INF/dependencymanager/ subdirectory.
>>
>> The question is, how are you debugging ? Are you doing something similar
>> to
>> what is described in the above link ?
>>
>> /Pierre
>>
>> On Wed, Jan 11, 2012 at 6:31 PM, Mohica Jasha <mohica.jasha@gmail.com
>> >wrote:
>>
>> > Hi Pierre,
>> >
>> > The pom file works for me. Thank you.
>> >
>> > I found out how to debug the code in in eclipse:
>> >
>> > When I build the package using maven the maven put an annotation
>> metadata
>> > file into the generated jar file in the target folder:
>> >
>> >
>> org.apache.felix.dependencymanager.samples.annotation.hello.jar:META-INF/dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
>> >
>> > The content of the file is the following:
>> >
>> >
>> {"impl":"org.apache.felix.dependencymanager.samples.annotation.hello","start":"activate","type":"Component"}
>> >
>> > But it doesn't add
>> >
>> >
>> dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
>> > into the META-INF folder of the project. (I don't know why though?!)
>> > If I manually copy the above file from the jar file into the
>> > META-INF/dependencymanager/ folder of the project, then the
>> corresponding
>> > service starts and eclipse can debug it.
>> >
>> > **A new Question**:
>> > Everytime I modify the annotation in a source file I have to run the
>> "mvn
>> > package" to create the target jar file and then copy the contents of
>> > META-INF/dependencymanager/* form the jar file into the
>> > META-INF/dependencymanager/ folder in the project. Is there a way to
>> make
>> > it automatic?
>> >
>> > Thanks,
>> > Mohica
>> >
>> >
>> >
>> > On Wed, Jan 11, 2012 at 5:55 AM, Pierre De Rop <pierre.derop@gmail.com
>> > >wrote:
>> >
>> > > Hello Mohica;
>> > >
>> > > Regarding your second question,
>> > >
>> > > if I understand correctly, you are trying to use an osgi bnd directive
>> > file
>> > > from maven, right ? Since the DM annotation API also contains a native
>> > bnd
>> > > plugin, then it is indeed possible to do this, and I think that the
>> root
>> > > cause of the NoClassDefFoundError is that you don't have added a
>> > dependency
>> > > over the DM annotation plugin inside the maven-bundle-plugin, and when
>> > bnd
>> > > tries to load the DM plugin (thanks to the -plugin option), then it
>> does
>> > > not find it because the dependency over
>> > > org.apache.felix.dependencymanager.annotation bundle is missing within
>> > the
>> > > maven-bundle-plugin.
>> > >
>> > > I have tried the following which works fine for me (I don't use a
>> > separate
>> > > osgi.bnd file but I rather declare the "_plugin" option in the
>> > > maven-bundle-plugin pom xml element, but I think it's similar to that
>> you
>> > > are doing). Notice that:
>> > >    - I use "_plugin" option from the maven-bundle-plugin instead of
>> > > "-plugin" bnd directive.
>> > >    - And since the DM annotation bnd plugin is invoked directly using
>> the
>> > > _plugin option, then it is not needed anymore to
>> > > declare the DM maven bundle plugin, which is useless in this case.
>> > >
>> > > Here it is:
>> > >
>> > >    <build>
>> > >        <plugins>
>> > >            <plugin>
>> > >                <groupId>org.apache.maven.plugins</groupId>
>> > >                <artifactId>maven-compiler-plugin</artifactId>
>> > >                <configuration>
>> > >                    <source>1.5</source>
>> > >                    <target>1.5</target>
>> > >                </configuration>
>> > >            </plugin>
>> > >            <plugin>
>> > >                <groupId>org.apache.felix</groupId>
>> > >                <artifactId>maven-bundle-plugin</artifactId>
>> > >                <version>2.3.4</version>
>> > >                <extensions>true</extensions>
>> > >                <configuration>
>> > >                    <instructions>
>> > >                        <Bundle-Name>Apache Felix Dependency Manager
>> > > Annotation Sample</Bundle-Name>
>> > >
>> > >
>> > >
>> >
>> <Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>
>> > >
>> > >
>> > >
>> >
>> <Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>
>> > >
>> > >
>> <Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
>> > >                        <!-- Ask bnd to load/run our dependency manager
>> > bnd
>> > > annotation plugin -->
>> > >
>> > >
>> > >
>> >
>> <_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
>> > >                    </instructions>
>> > >                </configuration>
>> > >                <dependencies>
>> > >                   <dependency>
>> > >                      <!-- Add our DM annotation plugin in bndlib class
>> > > path, allowing bnd to be
>> > >                             able to instantiate our DM plugin ... -->
>> > >                      <groupId>${pom.groupId}</groupId>
>> > >
>> > > <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
>> > >                      <version>3.0.0</version>
>> > >                   </dependency>
>> > >                 </dependencies>
>> > >            </plugin>
>> > >        </plugins>
>> > >    </build>
>> > >
>> > > Regarding your first question, I will get back to you later (tomorrow
>> if
>> > > possible).
>> > >
>> > > Hope this helps;
>> > > BR
>> > > /Pierre
>> > >
>> > > On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <mohica.jasha@gmail.com
>> > > >wrote:
>> > >
>> > > > Hi,
>> > > >
>> > > > 1. I am trying to control the dependencies of a bundle using felix
>> > > > annotations as explained here:
>> > > >
>> > > >
>> > >
>> >
>> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
>> > > > If I build the jar file out of the example and through it into felix
>> > > > launcher, it works perfectly, However I would like to debug the
>> bundle
>> > > > within eclipse, and I cannot launch the bundle.
>> > > >
>> > > > I tried so many ways but no luck. Any idea how I can debug the
>> bundle
>> > > > within eclipse?
>> > > >
>> > > > 2. I slightly changed the pom file to include the osgi.bnd file and
>> the
>> > > > "-plugin
>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn"
>> > line
>> > > > in the bnd file causes the following compilation error when I build
>> the
>> > > > project/package using maven:
>> > > >
>> > > > [WARNING] Warning building bundle
>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions in
>> > > > Private-Package, or -testpackages that are never used:
>> > > > mypackage\.dm\.testan\.testan
>> > > > Classpath:
>> > > >
>> > > >
>> > >
>> >
>> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
>> > > >
>> > > > [WARNING] Warning building bundle
>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
>> > > > directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
>> > > > [ERROR] Error building bundle
>> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem loading
>> > the
>> > > > plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
>> > > > exception: (java.lang.NoClassDefFoundError:
>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not
>> found,
>> > > > parent:  org.codehaus.classworlds.RealmClassLoader@585976c2 urls:[]
>> > > > exception:java.lang.ClassNotFoundException:
>> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
>> > > > [ERROR] Error(s) found in bundle configuration
>> > > > [INFO]
>> > > >
>> > ------------------------------------------------------------------------
>> > > > [ERROR] BUILD ERROR
>> > > > [INFO]
>> > > >
>> > ------------------------------------------------------------------------
>> > > > [INFO] Error(s) found in bundle configuration
>> > > >
>> > > > Thanks,
>> > > > Mohica
>> > > >
>> > >
>> >
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

Re: Felix DependencyManager with annotation/eclipse

Posted by Mohica Jasha <mo...@gmail.com>.
Hi Pierre,

Sorry for my late response.

How I debug in Eclipse:

I am using http://karaf.apache.org/ as my target platform and
http://code.google.com/a/eclipselabs.org/p/eik/ plugin which integrates
karaf with eclipse for debugging.
The way it works is that: I don't need to deploy the generated jar files
manually, but eclipse launches my existing Plug-in Project within the Karaf
OSGi-Framework.

I am not sure but I think the above method is under the "Using Pax Cursor
to launch easily any supported OSGi framework inside Eclipse." category in
the link you sent,
https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html



As I mentioned in the previous email, the jar file generated using "mvn
package" is flawless. The jar file HAS the META-INF/dependencymanager
sub-directory.

I have attached my project source code. After unzipping it you can simply
execute the following command to build it:
mvn clean package eclipse:eclipse -Declipse.pde install

The problem is eclipse needs META-INF/dependencymanager/ not only in the
jar file but also in the project folder hierarchy, i.e.,
com.myannotation.project/com.myannotation.testbundle/META-INF

After executing the mvn command the generated jar file has the
META-INF/dependencymanager/ subdirectory. But there is no dependencymanager
sub-directory inside the
com.myannotation.project/com.myannotation.testbundle/META-INF . So I cannot
debug from eclipse. If I manually copy dependencymanager from the jar file
to com.myannotation.project/com.myannotation.testbundle/META-INF/, then
debugging within eclipse will start to work.

My Question:
What modification should I make to my pom files to put dependencymanager
not only in the jar file but also in the project folder hierarchy, i.e.,
com.myannotation.project/com.myannotation.testbundle/META-INF/ ?

Thanks,
Mohica



On Thu, Jan 12, 2012 at 10:42 AM, Pierre De Rop <pi...@gmail.com>wrote:

> Hi Mohica,
>
> Good to know that you found how to debug using eclipse, may be you have
> read the following link ?
>
> https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html
>
> Now, I have tried to reproduce the issue you are describing, but I can't.
> When you change the annotation in the source file, you indeed have to
> recompile the project, by typing mvn package, or mvn install, and the
> descriptors are automatically generated and stored in the target bundle,
> under META-INF/dependencymanager/ subdirectory.
>
> The question is, how are you debugging ? Are you doing something similar to
> what is described in the above link ?
>
> /Pierre
>
> On Wed, Jan 11, 2012 at 6:31 PM, Mohica Jasha <mohica.jasha@gmail.com
> >wrote:
>
> > Hi Pierre,
> >
> > The pom file works for me. Thank you.
> >
> > I found out how to debug the code in in eclipse:
> >
> > When I build the package using maven the maven put an annotation metadata
> > file into the generated jar file in the target folder:
> >
> >
> org.apache.felix.dependencymanager.samples.annotation.hello.jar:META-INF/dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
> >
> > The content of the file is the following:
> >
> >
> {"impl":"org.apache.felix.dependencymanager.samples.annotation.hello","start":"activate","type":"Component"}
> >
> > But it doesn't add
> >
> >
> dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
> > into the META-INF folder of the project. (I don't know why though?!)
> > If I manually copy the above file from the jar file into the
> > META-INF/dependencymanager/ folder of the project, then the corresponding
> > service starts and eclipse can debug it.
> >
> > **A new Question**:
> > Everytime I modify the annotation in a source file I have to run the "mvn
> > package" to create the target jar file and then copy the contents of
> > META-INF/dependencymanager/* form the jar file into the
> > META-INF/dependencymanager/ folder in the project. Is there a way to make
> > it automatic?
> >
> > Thanks,
> > Mohica
> >
> >
> >
> > On Wed, Jan 11, 2012 at 5:55 AM, Pierre De Rop <pierre.derop@gmail.com
> > >wrote:
> >
> > > Hello Mohica;
> > >
> > > Regarding your second question,
> > >
> > > if I understand correctly, you are trying to use an osgi bnd directive
> > file
> > > from maven, right ? Since the DM annotation API also contains a native
> > bnd
> > > plugin, then it is indeed possible to do this, and I think that the
> root
> > > cause of the NoClassDefFoundError is that you don't have added a
> > dependency
> > > over the DM annotation plugin inside the maven-bundle-plugin, and when
> > bnd
> > > tries to load the DM plugin (thanks to the -plugin option), then it
> does
> > > not find it because the dependency over
> > > org.apache.felix.dependencymanager.annotation bundle is missing within
> > the
> > > maven-bundle-plugin.
> > >
> > > I have tried the following which works fine for me (I don't use a
> > separate
> > > osgi.bnd file but I rather declare the "_plugin" option in the
> > > maven-bundle-plugin pom xml element, but I think it's similar to that
> you
> > > are doing). Notice that:
> > >    - I use "_plugin" option from the maven-bundle-plugin instead of
> > > "-plugin" bnd directive.
> > >    - And since the DM annotation bnd plugin is invoked directly using
> the
> > > _plugin option, then it is not needed anymore to
> > > declare the DM maven bundle plugin, which is useless in this case.
> > >
> > > Here it is:
> > >
> > >    <build>
> > >        <plugins>
> > >            <plugin>
> > >                <groupId>org.apache.maven.plugins</groupId>
> > >                <artifactId>maven-compiler-plugin</artifactId>
> > >                <configuration>
> > >                    <source>1.5</source>
> > >                    <target>1.5</target>
> > >                </configuration>
> > >            </plugin>
> > >            <plugin>
> > >                <groupId>org.apache.felix</groupId>
> > >                <artifactId>maven-bundle-plugin</artifactId>
> > >                <version>2.3.4</version>
> > >                <extensions>true</extensions>
> > >                <configuration>
> > >                    <instructions>
> > >                        <Bundle-Name>Apache Felix Dependency Manager
> > > Annotation Sample</Bundle-Name>
> > >
> > >
> > >
> >
> <Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>
> > >
> > >
> > >
> >
> <Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>
> > >
> > >
> <Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
> > >                        <!-- Ask bnd to load/run our dependency manager
> > bnd
> > > annotation plugin -->
> > >
> > >
> > >
> >
> <_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
> > >                    </instructions>
> > >                </configuration>
> > >                <dependencies>
> > >                   <dependency>
> > >                      <!-- Add our DM annotation plugin in bndlib class
> > > path, allowing bnd to be
> > >                             able to instantiate our DM plugin ... -->
> > >                      <groupId>${pom.groupId}</groupId>
> > >
> > > <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
> > >                      <version>3.0.0</version>
> > >                   </dependency>
> > >                 </dependencies>
> > >            </plugin>
> > >        </plugins>
> > >    </build>
> > >
> > > Regarding your first question, I will get back to you later (tomorrow
> if
> > > possible).
> > >
> > > Hope this helps;
> > > BR
> > > /Pierre
> > >
> > > On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <mohica.jasha@gmail.com
> > > >wrote:
> > >
> > > > Hi,
> > > >
> > > > 1. I am trying to control the dependencies of a bundle using felix
> > > > annotations as explained here:
> > > >
> > > >
> > >
> >
> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
> > > > If I build the jar file out of the example and through it into felix
> > > > launcher, it works perfectly, However I would like to debug the
> bundle
> > > > within eclipse, and I cannot launch the bundle.
> > > >
> > > > I tried so many ways but no luck. Any idea how I can debug the bundle
> > > > within eclipse?
> > > >
> > > > 2. I slightly changed the pom file to include the osgi.bnd file and
> the
> > > > "-plugin
> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn"
> > line
> > > > in the bnd file causes the following compilation error when I build
> the
> > > > project/package using maven:
> > > >
> > > > [WARNING] Warning building bundle
> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions in
> > > > Private-Package, or -testpackages that are never used:
> > > > mypackage\.dm\.testan\.testan
> > > > Classpath:
> > > >
> > > >
> > >
> >
> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
> > > >
> > > > [WARNING] Warning building bundle
> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
> > > > directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
> > > > [ERROR] Error building bundle
> > > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem loading
> > the
> > > > plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
> > > > exception: (java.lang.NoClassDefFoundError:
> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not found,
> > > > parent:  org.codehaus.classworlds.RealmClassLoader@585976c2 urls:[]
> > > > exception:java.lang.ClassNotFoundException:
> > > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
> > > > [ERROR] Error(s) found in bundle configuration
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [ERROR] BUILD ERROR
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Error(s) found in bundle configuration
> > > >
> > > > Thanks,
> > > > Mohica
> > > >
> > >
> >
>

Re: Felix DependencyManager with annotation/eclipse

Posted by Pierre De Rop <pi...@gmail.com>.
Hi Mohica,

Good to know that you found how to debug using eclipse, may be you have
read the following link ?

https://cwiki.apache.org/FELIX/integrating-felix-with-eclipse.html

Now, I have tried to reproduce the issue you are describing, but I can't.
When you change the annotation in the source file, you indeed have to
recompile the project, by typing mvn package, or mvn install, and the
descriptors are automatically generated and stored in the target bundle,
under META-INF/dependencymanager/ subdirectory.

The question is, how are you debugging ? Are you doing something similar to
what is described in the above link ?

/Pierre

On Wed, Jan 11, 2012 at 6:31 PM, Mohica Jasha <mo...@gmail.com>wrote:

> Hi Pierre,
>
> The pom file works for me. Thank you.
>
> I found out how to debug the code in in eclipse:
>
> When I build the package using maven the maven put an annotation metadata
> file into the generated jar file in the target folder:
>
> org.apache.felix.dependencymanager.samples.annotation.hello.jar:META-INF/dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
>
> The content of the file is the following:
>
> {"impl":"org.apache.felix.dependencymanager.samples.annotation.hello","start":"activate","type":"Component"}
>
> But it doesn't add
>
> dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
> into the META-INF folder of the project. (I don't know why though?!)
> If I manually copy the above file from the jar file into the
> META-INF/dependencymanager/ folder of the project, then the corresponding
> service starts and eclipse can debug it.
>
> **A new Question**:
> Everytime I modify the annotation in a source file I have to run the "mvn
> package" to create the target jar file and then copy the contents of
> META-INF/dependencymanager/* form the jar file into the
> META-INF/dependencymanager/ folder in the project. Is there a way to make
> it automatic?
>
> Thanks,
> Mohica
>
>
>
> On Wed, Jan 11, 2012 at 5:55 AM, Pierre De Rop <pierre.derop@gmail.com
> >wrote:
>
> > Hello Mohica;
> >
> > Regarding your second question,
> >
> > if I understand correctly, you are trying to use an osgi bnd directive
> file
> > from maven, right ? Since the DM annotation API also contains a native
> bnd
> > plugin, then it is indeed possible to do this, and I think that the root
> > cause of the NoClassDefFoundError is that you don't have added a
> dependency
> > over the DM annotation plugin inside the maven-bundle-plugin, and when
> bnd
> > tries to load the DM plugin (thanks to the -plugin option), then it does
> > not find it because the dependency over
> > org.apache.felix.dependencymanager.annotation bundle is missing within
> the
> > maven-bundle-plugin.
> >
> > I have tried the following which works fine for me (I don't use a
> separate
> > osgi.bnd file but I rather declare the "_plugin" option in the
> > maven-bundle-plugin pom xml element, but I think it's similar to that you
> > are doing). Notice that:
> >    - I use "_plugin" option from the maven-bundle-plugin instead of
> > "-plugin" bnd directive.
> >    - And since the DM annotation bnd plugin is invoked directly using the
> > _plugin option, then it is not needed anymore to
> > declare the DM maven bundle plugin, which is useless in this case.
> >
> > Here it is:
> >
> >    <build>
> >        <plugins>
> >            <plugin>
> >                <groupId>org.apache.maven.plugins</groupId>
> >                <artifactId>maven-compiler-plugin</artifactId>
> >                <configuration>
> >                    <source>1.5</source>
> >                    <target>1.5</target>
> >                </configuration>
> >            </plugin>
> >            <plugin>
> >                <groupId>org.apache.felix</groupId>
> >                <artifactId>maven-bundle-plugin</artifactId>
> >                <version>2.3.4</version>
> >                <extensions>true</extensions>
> >                <configuration>
> >                    <instructions>
> >                        <Bundle-Name>Apache Felix Dependency Manager
> > Annotation Sample</Bundle-Name>
> >
> >
> >
> <Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>
> >
> >
> >
> <Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>
> >
> > <Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
> >                        <!-- Ask bnd to load/run our dependency manager
> bnd
> > annotation plugin -->
> >
> >
> >
> <_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
> >                    </instructions>
> >                </configuration>
> >                <dependencies>
> >                   <dependency>
> >                      <!-- Add our DM annotation plugin in bndlib class
> > path, allowing bnd to be
> >                             able to instantiate our DM plugin ... -->
> >                      <groupId>${pom.groupId}</groupId>
> >
> > <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
> >                      <version>3.0.0</version>
> >                   </dependency>
> >                 </dependencies>
> >            </plugin>
> >        </plugins>
> >    </build>
> >
> > Regarding your first question, I will get back to you later (tomorrow if
> > possible).
> >
> > Hope this helps;
> > BR
> > /Pierre
> >
> > On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <mohica.jasha@gmail.com
> > >wrote:
> >
> > > Hi,
> > >
> > > 1. I am trying to control the dependencies of a bundle using felix
> > > annotations as explained here:
> > >
> > >
> >
> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
> > > If I build the jar file out of the example and through it into felix
> > > launcher, it works perfectly, However I would like to debug the bundle
> > > within eclipse, and I cannot launch the bundle.
> > >
> > > I tried so many ways but no luck. Any idea how I can debug the bundle
> > > within eclipse?
> > >
> > > 2. I slightly changed the pom file to include the osgi.bnd file and the
> > > "-plugin
> > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn"
> line
> > > in the bnd file causes the following compilation error when I build the
> > > project/package using maven:
> > >
> > > [WARNING] Warning building bundle
> > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions in
> > > Private-Package, or -testpackages that are never used:
> > > mypackage\.dm\.testan\.testan
> > > Classpath:
> > >
> > >
> >
> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
> > >
> > > [WARNING] Warning building bundle
> > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
> > > directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
> > > [ERROR] Error building bundle
> > > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem loading
> the
> > > plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
> > > exception: (java.lang.NoClassDefFoundError:
> > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not found,
> > > parent:  org.codehaus.classworlds.RealmClassLoader@585976c2 urls:[]
> > > exception:java.lang.ClassNotFoundException:
> > > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
> > > [ERROR] Error(s) found in bundle configuration
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [ERROR] BUILD ERROR
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Error(s) found in bundle configuration
> > >
> > > Thanks,
> > > Mohica
> > >
> >
>

Re: Felix DependencyManager with annotation/eclipse

Posted by Mohica Jasha <mo...@gmail.com>.
Hi Pierre,

The pom file works for me. Thank you.

I found out how to debug the code in in eclipse:

When I build the package using maven the maven put an annotation metadata
file into the generated jar file in the target folder:
org.apache.felix.dependencymanager.samples.annotation.hello.jar:META-INF/dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello

The content of the file is the following:
{"impl":"org.apache.felix.dependencymanager.samples.annotation.hello","start":"activate","type":"Component"}

But it doesn't add
dependencymanager/org.apache.felix.dependencymanager.samples.annotation.hello
into the META-INF folder of the project. (I don't know why though?!)
If I manually copy the above file from the jar file into the
META-INF/dependencymanager/ folder of the project, then the corresponding
service starts and eclipse can debug it.

**A new Question**:
Everytime I modify the annotation in a source file I have to run the "mvn
package" to create the target jar file and then copy the contents of
META-INF/dependencymanager/* form the jar file into the
META-INF/dependencymanager/ folder in the project. Is there a way to make
it automatic?

Thanks,
Mohica



On Wed, Jan 11, 2012 at 5:55 AM, Pierre De Rop <pi...@gmail.com>wrote:

> Hello Mohica;
>
> Regarding your second question,
>
> if I understand correctly, you are trying to use an osgi bnd directive file
> from maven, right ? Since the DM annotation API also contains a native bnd
> plugin, then it is indeed possible to do this, and I think that the root
> cause of the NoClassDefFoundError is that you don't have added a dependency
> over the DM annotation plugin inside the maven-bundle-plugin, and when bnd
> tries to load the DM plugin (thanks to the -plugin option), then it does
> not find it because the dependency over
> org.apache.felix.dependencymanager.annotation bundle is missing within the
> maven-bundle-plugin.
>
> I have tried the following which works fine for me (I don't use a separate
> osgi.bnd file but I rather declare the "_plugin" option in the
> maven-bundle-plugin pom xml element, but I think it's similar to that you
> are doing). Notice that:
>    - I use "_plugin" option from the maven-bundle-plugin instead of
> "-plugin" bnd directive.
>    - And since the DM annotation bnd plugin is invoked directly using the
> _plugin option, then it is not needed anymore to
> declare the DM maven bundle plugin, which is useless in this case.
>
> Here it is:
>
>    <build>
>        <plugins>
>            <plugin>
>                <groupId>org.apache.maven.plugins</groupId>
>                <artifactId>maven-compiler-plugin</artifactId>
>                <configuration>
>                    <source>1.5</source>
>                    <target>1.5</target>
>                </configuration>
>            </plugin>
>            <plugin>
>                <groupId>org.apache.felix</groupId>
>                <artifactId>maven-bundle-plugin</artifactId>
>                <version>2.3.4</version>
>                <extensions>true</extensions>
>                <configuration>
>                    <instructions>
>                        <Bundle-Name>Apache Felix Dependency Manager
> Annotation Sample</Bundle-Name>
>
>
> <Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>
>
>
> <Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>
>
> <Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
>                        <!-- Ask bnd to load/run our dependency manager bnd
> annotation plugin -->
>
>
> <_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
>                    </instructions>
>                </configuration>
>                <dependencies>
>                   <dependency>
>                      <!-- Add our DM annotation plugin in bndlib class
> path, allowing bnd to be
>                             able to instantiate our DM plugin ... -->
>                      <groupId>${pom.groupId}</groupId>
>
> <artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
>                      <version>3.0.0</version>
>                   </dependency>
>                 </dependencies>
>            </plugin>
>        </plugins>
>    </build>
>
> Regarding your first question, I will get back to you later (tomorrow if
> possible).
>
> Hope this helps;
> BR
> /Pierre
>
> On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <mohica.jasha@gmail.com
> >wrote:
>
> > Hi,
> >
> > 1. I am trying to control the dependencies of a bundle using felix
> > annotations as explained here:
> >
> >
> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
> > If I build the jar file out of the example and through it into felix
> > launcher, it works perfectly, However I would like to debug the bundle
> > within eclipse, and I cannot launch the bundle.
> >
> > I tried so many ways but no luck. Any idea how I can debug the bundle
> > within eclipse?
> >
> > 2. I slightly changed the pom file to include the osgi.bnd file and the
> > "-plugin
> > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn" line
> > in the bnd file causes the following compilation error when I build the
> > project/package using maven:
> >
> > [WARNING] Warning building bundle
> > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions in
> > Private-Package, or -testpackages that are never used:
> > mypackage\.dm\.testan\.testan
> > Classpath:
> >
> >
> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
> >
> > [WARNING] Warning building bundle
> > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
> > directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
> > [ERROR] Error building bundle
> > mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem loading the
> > plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
> > exception: (java.lang.NoClassDefFoundError:
> > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not found,
> > parent:  org.codehaus.classworlds.RealmClassLoader@585976c2 urls:[]
> > exception:java.lang.ClassNotFoundException:
> > org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
> > [ERROR] Error(s) found in bundle configuration
> > [INFO]
> > ------------------------------------------------------------------------
> > [ERROR] BUILD ERROR
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Error(s) found in bundle configuration
> >
> > Thanks,
> > Mohica
> >
>

Re: Felix DependencyManager with annotation/eclipse

Posted by Pierre De Rop <pi...@gmail.com>.
Hello Mohica;

Regarding your second question,

if I understand correctly, you are trying to use an osgi bnd directive file
from maven, right ? Since the DM annotation API also contains a native bnd
plugin, then it is indeed possible to do this, and I think that the root
cause of the NoClassDefFoundError is that you don't have added a dependency
over the DM annotation plugin inside the maven-bundle-plugin, and when bnd
tries to load the DM plugin (thanks to the -plugin option), then it does
not find it because the dependency over
org.apache.felix.dependencymanager.annotation bundle is missing within the
maven-bundle-plugin.

I have tried the following which works fine for me (I don't use a separate
osgi.bnd file but I rather declare the "_plugin" option in the
maven-bundle-plugin pom xml element, but I think it's similar to that you
are doing). Notice that:
    - I use "_plugin" option from the maven-bundle-plugin instead of
"-plugin" bnd directive.
    - And since the DM annotation bnd plugin is invoked directly using the
_plugin option, then it is not needed anymore to
declare the DM maven bundle plugin, which is useless in this case.

Here it is:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.4</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Name>Apache Felix Dependency Manager
Annotation Sample</Bundle-Name>

<Bundle-SymbolicName>org.apache.felix.dependencymanager.samples.annotation</Bundle-SymbolicName>

<Import-Package>org.apache.felix.service.command;status=provisional,*</Import-Package>

<Private-Package>org.apache.felix.dm.samples.annotation</Private-Package>
                        <!-- Ask bnd to load/run our dependency manager bnd
annotation plugin -->

<_plugin>org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug</_plugin>
                    </instructions>
                </configuration>
                <dependencies>
                   <dependency>
                      <!-- Add our DM annotation plugin in bndlib class
path, allowing bnd to be
                             able to instantiate our DM plugin ... -->
                      <groupId>${pom.groupId}</groupId>

<artifactId>org.apache.felix.dependencymanager.annotation</artifactId>
                      <version>3.0.0</version>
                   </dependency>
                 </dependencies>
            </plugin>
        </plugins>
    </build>

Regarding your first question, I will get back to you later (tomorrow if
possible).

Hope this helps;
BR
/Pierre

On Tue, Jan 10, 2012 at 9:47 PM, Mohica Jasha <mo...@gmail.com>wrote:

> Hi,
>
> 1. I am trying to control the dependencies of a bundle using felix
> annotations as explained here:
>
> http://felix.apache.org/site/apache-felix-dependency-manager-using-annotations-quick-start.html
> If I build the jar file out of the example and through it into felix
> launcher, it works perfectly, However I would like to debug the bundle
> within eclipse, and I cannot launch the bundle.
>
> I tried so many ways but no luck. Any idea how I can debug the bundle
> within eclipse?
>
> 2. I slightly changed the pom file to include the osgi.bnd file and the
> "-plugin
> org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn" line
> in the bnd file causes the following compilation error when I build the
> project/package using maven:
>
> [WARNING] Warning building bundle
> mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Instructions in
> Private-Package, or -testpackages that are never used:
> mypackage\.dm\.testan\.testan
> Classpath:
>
> Jar:.,Jar:osgi_R4_core,Jar:osgi_R4_compendium,Jar:org.apache.felix.dependencymanager.annotation,Jar:org.osgi.core,Jar:bndlib,Jar:maven-project,Jar:maven-settings,Jar:maven-model,Jar:plexus-utils,Jar:plexus-container-default,Jar:junit,Jar:classworlds,Jar:maven-profile,Jar:maven-artifact-manager,Jar:maven-repository-metadata,Jar:maven-artifact,Jar:wagon-provider-api,Jar:maven-plugin-registry,Jar:maven-plugin-api,Jar:json,Jar:.,Jar:org.apache.felix.dependencymanager.annotation-3.0.0
>
> [WARNING] Warning building bundle
> mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : No sub JAR or
> directory org.apache.felix.dependencymanager.annotation-3.0.0.jar
> [ERROR] Error building bundle
> mypackage:mypackage.dm.testan2:bundle:1.0-SNAPSHOT : Problem loading the
> plugin: org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin
> exception: (java.lang.NoClassDefFoundError:
> org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin not found,
> parent:  org.codehaus.classworlds.RealmClassLoader@585976c2 urls:[]
> exception:java.lang.ClassNotFoundException:
> org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin)
> [ERROR] Error(s) found in bundle configuration
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Error(s) found in bundle configuration
>
> Thanks,
> Mohica
>