简体   繁体   中英

OSGi maven-bundle-plugin leaving out my package

I've got a CXF web service app in Fuse, and it's got a reference in a camel context xml file to a jar containing my files generated from a WSDL.

<cxf:cxfEndpoint id="LookupEndpoint"
                 address="${my.LookupUri}"
                 serviceClass="com.whatever.IWebService"
                 wsdlURL="wsdl/MyWsdl.wsdl"/>  

com.whatever.* is in my <Import-Package> list. The jar is in my maven dependencies. I can say import com.whatever.IWebService; and it doesn't complain.

But maven-bundle-plugin doesn't include this package in the MANIFEST.MF

It includes all my other packages that I requested. But not this one. So in Fuse, when I deploy it, I get ClassNotFoundException, referring to the context.xml class loading.

It is very frustrating. Is there a way to maybe force the plugin to import a certain package? Because their auto-magical dependency solver is ignoring my <Import-Package>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>${version.maven-bundle-plugin}</version>
            <extensions>true</extensions>

            <configuration>
                <manifestLocation>src/main/resources/META-INF</manifestLocation>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Version>${project.version}</Bundle-Version>

                     <Import-Package> 
                     *, 
                     com.imports.this.one.fine*,
                     com.imports.this.one.just.fine*,
                     com.imports.does.not.import.this.one.*,
                    </Import-Package> 

                    <Export-Package>
                    com.something.export.*
                    </Export-Package>

                </instructions>
            </configuration>
        </plugin>

When you use <Import-Package> with a wildcard, then an OSGi Import-Package header is generated for all packages matching the wildcard that the code in your bundle depends on .

If the maven-bundle-plugin is not generating an import for the package you expect, it means that the code in your bundle doesn't actually reference that package.

Rather than importing this package, shouldn't it be included in the bundle?? Why do you want to import it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM