Question

I'm new to OSGi, coded only a few bundles and deployed them manually. Some friends of mine told me about Virgo and Virgo tools, which allows you to auto-deploy bundles you manage with eclipse.

I'm currently trying to set all this up. I have virgo-tomcat-server-3.5.0.RELEASE, along with virgo tools 1.0.0, all of this installed on a Spring Tool Suite 3.1.0.RELEASE (in case you don't know, this last one includes the m2eclipse plugin).

My bundle is a maven project. It uses the bnd plugin and here's its configuration

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
    <instructions>
        <Export-Package>fr.tpepio.mtg.model</Export-Package>
    </instructions>
</configuration>
<executions>
    <execution>
        <id>build-manifest</id>
        <phase>compile</phase>
        <goals>
            <goal>manifest</goal>                           
        </goals>                        
    </execution>
</executions>

You can see that I export only one package. I also try to make m2eclipse to dynamically generate my manifest.mf file when eclipse compiles my classes.

I finally get to the issues I'm facing.

  1. Since I import my bundle as a maven project into STS, I have to add the Virgo facet to it. And as soon as I update my maven configuration, it kind of screws my projects and I get the following error :

    Java compiler level does not match the version of the installed Java project facet.
    
  2. Appart from my (shitty) maven configuration, I have found myself unable to add my project into the virgo server, which endlessly tells me

    null reason : null
    

Does someone has any clue ?

Was it helpful?

Solution

Hurray ! Problems solved.

First : about the java compiler and facet's java version. Telling maven that your sources are coded in 1.6, and must be compiled in 1.6 will resolve the problem. Code is the following :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<inherited>true</inherited>
<configuration>
    <verbose>false</verbose>
    <encoding>${java.compiler.encoding}</encoding>
    <fork>true</fork>
    <source>${java.compile.version}</source>
    <target>${java.compile.version}</target>
</configuration>

I still don't understand why it resolves this problem, since both my project configuration and STS configuration could only use java 6... I believe this is because my sources where compiled as 1.5 java sources.

Second : adding the maven bundle project to virgo.

  1. Configure correctly bnd, by running its "manifest" goal in the right maven phase (e.g. : after your classes have been compiled), and tell him where he can find the manifest. This solves the "null reason : null" issue (maybe virgo should have said : "could not find manifest.mf... ?).

    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
            <instructions>
                    <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Name>${project.name}</Bundle-Name>
                    <Bundle-Version>${project.version}</Bundle-Version>
                    <Bundle-ClassPath>.</Bundle-ClassPath>
                    <Export-Package>
                            [packages you want to export]
                    </Export-Package>
            </instructions>
    </configuration>
    <executions>
            <execution>
                    <id>bundle-manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                            <goal>manifest</goal>
                    </goals>
                    <configuration>
                            <manifestLocation>src/main/resources/META-INF/</manifestLocation>
                    </configuration>
            </execution>
    </executions>
    

  2. Add this goal to the m2eclipse lifecycle mapping. This refreshes your manifest after each occurence of the phase you indicated in your bnd configuration (here : the process-classes phases). Otherwise, m2eclipse has no way to understand when it should call your goal.

    <pluginManagement>
    <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                            <lifecycleMappingMetadata>
                                    <pluginExecutions>
                                            <!-- Maven Bundle Plugin -->
                                            <pluginExecution>
                                                    <pluginExecutionFilter>
                                                            <groupId>org.apache.felix</groupId>
                                                            <artifactId>maven-bundle-plugin</artifactId>
                                                            <versionRange>[2.3.7,)</versionRange>
                                                            <goals>
                                                                    <goal>manifest</goal>
                                                            </goals>
                                                    </pluginExecutionFilter>
                                                    <action>
                                                            <execute>
                                                                    <runOnIncremental>false</runOnIncremental>
                                                            </execute>
                                                    </action>
                                            </pluginExecution>
                                    </pluginExecutions>
                            </lifecycleMappingMetadata>
                    </configuration>
            </plugin>
    </plugins>
    

Hope this wil help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top