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.de...@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.ja...@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
> >
>

Reply via email to