Search code examples
mavenaemapache-felixosgi-bundle

Not able to install bundle in felix console through maven


I am trying to install my bundle into felix console by using maven.

Here is the thing that I did differently is,

I created my own user (other than admin) and put that user in administrator group. Also I added my new user in Apache Web Console Security Provider. By this I am able to access and install bundle in localhost:4502/system/console/bundles. But if I try to use maven for same work than it gives following exception.

[ERROR] Failed to execute goal com.day.jcr.vault:content-package-maven-plugin:0.0.20:install (install-content-package) on project testUser-content: Error while
 installing package. Check log for details. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.day.jcr.vault:content-package-maven-plugin:0.0.20:install (install-content-p
ackage) on project testUser-content: Error while installing package. Check log for details.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Error while installing package. Check log for details.
        at com.day.jcr.vault.maven.mgr.PackageInstallMojo.uploadPackage(PackageInstallMojo.java:281)
        at com.day.jcr.vault.maven.mgr.PackageInstallMojo.execute(PackageInstallMojo.java:200)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        ... 20 more

Solution

  • The stack trace shared in the description indicates that the wrong maven plugin (content-package-maven-plugin) is invoked in order to install a bundle artifact.

    A correct Maven plugin able to install bundle artifact is the Maven Sling Plugin (maven-sling-plugin).

    In order to use the maven-sling-plugin plugin, add the following in the build section of any pom.xml which produces bundle (the packaging tag of the artifact is bundle).

    <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>maven-sling-plugin</artifactId>
        <version>2.1.8</version>
    </plugin>
    

    Then install the bundle by invoking the plugin as follow

    $ mvn sling:install -Dsling.url=<host>:<port>/system/console
    

    The sling.url and various other parameters can be configured once as part of your pom.xml. Please check the complete plugin documentation.