1

I'm trying to use the iPojo annotations for component declaration inside Eclipse. The issue is that when it's generating the XML and modified classes the bnd-ipojo-plugin can't find the annotations in the plugin classpath.

I get errors in Eclipse like this:

During generation of a component on class org.osgi.example.Application, exception java.lang.ClassNotFoundException: org.apache.felix.ipojo.annotations.Bind

I have modified the .bnd file to contain the '-plugins' property:

-plugin: org.apache.felix.ipojo.bnd.PojoizationPlugin;use-local-schemas=true;path:="${workspace}/cnf/plugins/org.apache.felix.ipojo-1.10.1.jar;${workspace}/cnf/plugins/org.apache.felix.ipojo.annotations-1.10.1.jar;${workspace}/cnf/plugins/bnd-ipojo-plugin-1.10.1.jar;${workspace}/cnf/plugins/org.apache.felix.ipojo.manipulator-1.10.1.jar"

My Eclipse project has all the iPojo jars in the BuildPath as well. Does anyone have any suggestions? Or is there a better way to integrate iPojo into Eclipse?

Edit 1

I have completely rebuilt my workspace and moved the -plugin and -pluginpath variables to the build.bnd file.

It now looks something like this:

-pluginpath: ${plugindir}/biz.aQute.repository/biz.aQute.repository-2.1.0.jar,\
    ${plugindir}/bnd-ipojo-plugin/bnd-ipojo-plugin-1.10.1.jar, \
    ${plugindir}/org.apache.felix.ipojo/org.apache.felix.ipojo-1.10.1.jar, \
    ${plugindir}/org.apache.felix.ipojo.annotations/org.apache.felix.ipojo.annotations-1.10.1.jar, \
    ${plugindir}/org.apache.felix.ipojo.manipulator/org.apache.felix.ipojo.manipulator-1.10.1.jar

-plugin: aQute.bnd.deployer.repository.LocalIndexedRepo;name=Release;local=${workspace}/cnf/releaserepo;pretty=true,\
    aQute.bnd.deployer.repository.LocalIndexedRepo;name=Local;local=${workspace}/cnf/localrepo;pretty=true,\
    aQute.bnd.deployer.repository.FixedIndexedRepo;name=Bndtools Hub;locations=https://github.com/bndtools/bundle-hub/raw/master/index.xml.gz,\
    aQute.lib.deployer.FileRepo;name=Build;location=${workspace}/cnf/buildrepo,\
    aQute.lib.deployer.FileRepo;readonly=true;name=iPojo Repo;location=${plugindir}, \
    org.apache.felix.ipojo.bnd.PojoizationPlugin;use-local-schemas=true

Now all the errors are gone and it builds without failing. However, the XML files are still not being generated. Is there another step besides altering the build.bnd file?

max
  • 2,346
  • 4
  • 26
  • 34
  • Have you set the -plugins property in cnf/build.bnd? It doesn't work if you put it in a project bnd.bnd file. – Neil Bartlett Sep 07 '13 at 17:29
  • Thanks. I wasn't sure which one it went it. I've moved it to build.bnd and updated the question. – max Sep 08 '13 at 05:29
  • Unfortunately I don't know much about iPOJO so I don't know what it's supposed to generate and where. But have you checked in the Eclipse Error Log view? If something is going wrong then you will hopefully find some errors in there. – Neil Bartlett Sep 08 '13 at 21:09
  • Thanks Neil. I'll look there for some answers. Is there an annotation lib that you can suggest for eclipse? – max Sep 08 '13 at 21:39

2 Answers2

0

I had the same problem and got it working by building the bnd-ipojo-plugin as a fat jar with all dependencies. I got the idea from here: https://groups.google.com/forum/#!topic/bndtools-users/0IqYbXOxn3Q

I took the source and added this to the pom.xml:

...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
    </configuration>
    <executions>
        <execution>
            <id>assemble-all</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>
...

Then I added the resulting jar as a plugin to build.bnd like that:

-plugin: org.apache.felix.ipojo.bnd.PojoizationPlugin;path:="${workspace}/cnf/plugins/bnd-ipojo-plugin-1.12.1-jar-with-dependencies.jar";use-local-schemas=true

With that it works properly.

mapf
  • 496
  • 1
  • 5
  • 21
-1

I switched to BndTools SCR annotations over iPojo. I liked the expressiveness of the iPojo annotations, but I found the SCR annotations to be just as enjoyable. Since they are built into BndTools, they work as expected. Although the specification (pg. 187) proved very useful in making sure I was using them correctly (ie. properties vs property).

max
  • 2,346
  • 4
  • 26
  • 34