Apache OSGI Karaf's features-maven-plugin:create-kar is failing on a features.xml bundle using the PAX wrap/bnd syntax

StackOverflow https://stackoverflow.com/questions/15375077

Question

The problematic line is the first bundle in this features snippet

<feature name="stuff-common-security">
    <bundle>wrap:mvn:org.springframework/ldap/1.3.0.RELEASE,mvn:com.mycompany.stuff/stuff-common-security/1.0-SNAPSHOT/bnd/spring-ldap</bundle>
    <bundle>mvn:org.springframework.security/spring-security-core/3.1.0.RELEASE</bundle>
    <bundle>mvn:org.springframework.security/spring-security-ldap/3.1.0.RELEASE</bundle>
    <bundle>mvn:com.mycompany.stuff/stuff-common-security/1.0-SNAPSHOT</bundle>
</feature>

The create-kar goal fails with this error:

[ERROR] Failed to execute goal org.apache.karaf.tooling:features-maven-plugin:2.2.9:create-kar (create-kar) on project stuff-demo:
 Failed to create kar archive: 
 Could not find artifact org.springframework:ldap:stuff-common-security:1.0-SNAPSHOT:1.3.0.RELEASE,mvn:com.mycompany.stuff 
in maven.mycompany.com (http://maven.mycompany.com/artifactory/libs-release-local)
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.springframework -DartifactId=ldap 
       -Dversion=1.3.0.RELEASE,mvn:com.mycompany.stuff -Dclassifier=1.0-SNAPSHOT 
       -Dpackaging=stuff-common-security -Dfile=/path/to/file

It seems to be misparsing that bundle element text and treating the wrapper as part of the version number.

<bundle>wrap:mvn:org.springframework/ldap/1.3.0.RELEASE,mvn:com.mycompany.stuff/stuff-common-security/1.0-SNAPSHOT/bnd/spring-ldap</bundle>

Karaf itself is happy as a clam with this bundle syntax, so I don't think I made an error there.

Is there an alternative way I can express this so I don't get this error from create-kar?

Was it helpful?

Solution

Try escaping the comma with a '\' or using a CDATA section (I had some escaping issues noted on mailing list):

<bundle><![CDATA[
wrap:mvn:org.springframework/ldap/1.3.0.RELEASE,mvn:com.mycompany.stuff/stuff-common-security/1.0-SNAPSHOT/bnd/spring-ldap
]]></bundle>

If that doesn't work - I'd suspect the plugin is not using actual URL handlers and is just stripping off the wrap protocol, so would suggest filing a bug

As you're using classifiers you might want to just do the embed in the pom for stuff-common-security but that might make your build a bit too hairy =]

If so create a maven module with only those two modules as dependencies then use the BND/maven-bundle-plugin's embed dependencies to merge them.

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