Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Deploying bundles with Maven on publish instance

Avatar

Former Community Member

Hi Guys,

I'm trying to create a script that builds a publish instance in an automatic way, and I'm having problems when I try to deploy two bundles (custom authenticator and custom login module) using maven with start leven 15.

I'm having the same problem with both, so I'll use on as an example:

For what I could found online, in tutorials and discussions, my top level maven configuration profiles section looks like this:

    <profiles>
        <profile>
            <id>installPackage</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>com.day.jcr.vault</groupId>
                            <artifactId>content-package-maven-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>content-package-install</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>install</goal>
                                    </goals>
                                    <configuration>
                                        <userId>admin</userId>
                                        <password>admin</password>
                                        <targetURL>http://${crx.host}:${crx.port}/crx/packmgr/service.jsp</targetURL>
                                        <verbose>true</verbose>
                                        <failOnError>true</failOnError>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>        
        <profile>
            <id>autoInstallBundle</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>maven-sling-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-bundle</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                  <configuration>
                                    <slingUrl>${crx.url}/system/console/install</slingUrl>
                                    <user>${crx.user}</user>
                                    <password>${crx.password}</password>
                                    <bundleStartLevel>15</bundleStartLevel>
                                  </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

 

Case 1) When I run mvn clean install -P installPackage, the bundle gets deployed, but with level 20 (and it has to be 15).

Case 2) When I run mvn -P autoInstallBundle install, I get the following message:

    C:\development\CQ5\AEM561\CQ5\test-publish\projects\authentication\content\target\authentication-content-1.0-SNAPSHOT.jar is not an OSGi Bundle, not uploading

            What it's happening here is that maven tries to deploy my content project as a bundle, instead of my bundle project.

Case 3) I went further and added the autoInstallBundle profile to my bundle's projects pom (instead of the root one). But when I try to run mvn -P autoInstallBundle install, inside the bundle directory I'm getting the following error message:

 

[INFO] --- maven-sling-plugin:2.0.6:install (install-package) @ login-bundle ---
[INFO] Installing Bundle com.avatarla.televisa.login-bundle(C:\development\CQ5\AEM561\CQ5\test-publish\projects\login\bundle\target\login-bundle-1.0-SNAPSHOT.jar) to http://localhost:4503/system/console/install via PUT
[ERROR] Installation failed, cause: Method Not Allowed

   

Do you have any idea of what might be happening and how to solve it?

Thanks in advance,

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

If you need to install your bundle for a particular start level (and you really should try to avoid this, but that's a separate issue), you should not embed it in a content package and/or use JCR Installer. Rather you should only install via the web console.

In specific response to your cases:

Case #1: Invalid. Don't embed the bundle and don't try to install it using the JCR Installer.

Case #2: This is caused because you have the autoInstallBundle profile defined on the aggregator/reactor POM. Instead, define it only on the bundle project.

Case #3: This because your configuration is incorrect in at least two aspects. (1) You are using the usePut option when trying to install via the web console (which doesn't support PUT) and (2) the URL should be /system/console/bundles, not /system/console/install.

Regards,

Justin

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Hi,

If you need to install your bundle for a particular start level (and you really should try to avoid this, but that's a separate issue), you should not embed it in a content package and/or use JCR Installer. Rather you should only install via the web console.

In specific response to your cases:

Case #1: Invalid. Don't embed the bundle and don't try to install it using the JCR Installer.

Case #2: This is caused because you have the autoInstallBundle profile defined on the aggregator/reactor POM. Instead, define it only on the bundle project.

Case #3: This because your configuration is incorrect in at least two aspects. (1) You are using the usePut option when trying to install via the web console (which doesn't support PUT) and (2) the URL should be /system/console/bundles, not /system/console/install.

Regards,

Justin

Avatar

Former Community Member

Justin,

Thank you very much for your response. I missed the generated "usePut" parameter  (I guess it was set by the archetype).

With your indications I made it work perfectly.

Thanks again.

Regards,