Domanda

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?

È stato utile?

Soluzione 2

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).

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top