Search code examples
javaosgimaven-2apache-servicemix

Deploying a Maven Built OSGi Package in ServiceMix: "Unresolved constraint in bundle ..."


I can build my projects "samba.interfaces" and "samba.message" without problems. But when I try to start "samba.message" bundle in ServiceMix (requires the "samba.interfaces" bundle that contains the package de.samba.common), I get the following error:

Error executing command: Unresolved constraint in bundle message [195]: module; 
(&(bundle-symbolic-name=de.samba.common)(bundle-version>=0.0.1))

So, what is the symbolic name used for? Does it have to be the same as the main package? This is the part of the POM that specifies the message bundle:

<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
             <version>2.2.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-Activator>de.samba.message.Activator</Bundle-Activator>
                    <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Name>SAMBA Message</Bundle-Name>
                    <Bundle-Version>1.0.0</Bundle-Version>
                    <Import-Package>
                        javax.jws,
                        javax.wsdl,
                        javax.xml.bind,
                        javax.xml.bind.annotation,
                        javax.xml.namespace,
                        javax.xml.ws,
                        META-INF.cxf,
                        META-INF.cxf.osgi,
                        org.apache.cxf.endpoint,
                        org.apache.cxf.bus,
                        org.apache.cxf.bus.spring,
                        org.apache.cxf.bus.resource,
                        org.apache.cxf.configuration.spring,
                        org.apache.cxf.resource,
                        org.apache.cxf.service.model,
                        org.apache.cxf.jaxws,
                        org.apache.cxf.transport.http_osgi,
                        org.springframework.beans.factory.config,
                        org.springframework.beans.factory.xml,
                        org.springframework.core.io,
                        org.springframework.beans.factory, 
                        org.springframework.context.support,
                        org.springframework.beans, 
                        org.springframework.context, 
                        org.osgi.framework,
                        org.apache.log4j,
                        de.samba.common.auditingcontrol.*,
                        de.samba.common.collect.*,
                        de.samba.common.message.*,
                        de.samba.common.repository.*,
                        de.samba.common.security.*,
                        de.samba.common,
                        *
                    </Import-Package>
                    <Export-Package>de.samba.message.*</Export-Package>
                    <Private-Package>

                    </Private-Package>
                    <!--
                    <DynamicImport-Package>*</DynamicImport-Package>
                    -->
                </instructions>

Any ideas what might cause this error?


Solution

  • Okay, I found the problem myself. Error executing command: Unresolved constraint in bundle message [195]: module; (&(bundle-symbolic-name=de.samba.common)(bundle-version>=0.0.1)) was completely unexpected, and it came from having a MANIFEST.MF file inside src/main/resources/META-INF that usually describes the bundle information if you're doing plugin/OSGi development. Seems that the Maven BND Plugin includes that file and ONLY generates new information if it isn't there.

    So the problem was solved after removing src/main/resources/META-INF/MANIFEST.MF so the plugin could generate the proper one.