2 Replies Latest reply on Mar 14, 2013 5:09 PM by bwallis42

    jboss-as-maven-plugin and repository creation/deletion

    bwallis42

      Has anyone got experience using the jboss-as-maven-plugin to create and remove repositories with their associated infinispan cache container and caches?

       

      I have the following in a pom.xml file

       


      {code}

                  <plugin>

                      <groupId>org.jboss.as.plugins</groupId>

                      <artifactId>jboss-as-maven-plugin</artifactId>

                      <executions>

                     

                          <!-- next add the infinispan cache-container and cache we will use behind the modeshape repository -->

                          <execution>

                              <id>add-cache-container</id>

                              <phase>install</phase>

                              <goals>

                                  <goal>add-resource</goal>

                              </goals>

                              <configuration>

                                  <address>subsystem=infinispan</address>

                                  <resources>

                                      <resource>

                                          <address>cache-container=cpf4-modeshape</address>

                                          <properties>

                                              <default-cache>cpf4</default-cache>

                                          </properties>

                                      </resource>

                                      <resource>

                                          <address>cache-container=cpf4-modeshape,local-cache=cpf4</address>

                                      </resource>

                                      <resource>

                                          <address>cache-container=cpf4-modeshape,local-cache=cpf4,file-store=FILE_STORE</address>

                                          <properties>

                                              <relative-to>jboss.server.data.dir</relative-to>

                                              <path>modeshape/store/cpf4</path>

                                              <passivation>false</passivation>

                                              <purge>false</purge>

                                          </properties>

                                      </resource>

                                  </resources>

                                  <hostname>${jboss.hostname}</hostname>

                                  <port>${jboss.adminport}</port>

                                  <username>${jboss.adminuser}</username>

                                  <password>${jboss.adminpasswd}</password>

                              </configuration>

                          </execution>

                         

                          <!-- now add a modeshape repository for the document store -->

                          <execution>

                              <id>add-repository</id>

                              <phase>install</phase>

                              <goals>

                                  <goal>add-resource</goal>

                              </goals>

                              <configuration>

                                  <address>subsystem=modeshape</address>

                                  <resource>

                                      <address>repository=cpf4</address>

                                      <properties>

                                          <cache-container>cpf4-modeshape</cache-container>

                                          <cache-name>cpf4</cache-name>

                                      </properties>

                                  </resource>

                                  <hostname>${jboss.hostname}</hostname>

                                  <port>${jboss.adminport}</port>

                                  <username>${jboss.adminuser}</username>

                                  <password>${jboss.adminpasswd}</password>

                              </configuration>

                          </execution>

                         

                              <!-- ... other deployment stuff, ears and wars -->

       

                          <!-- Undeploy the application and resources during the clean phase -->

                          <!-- Try to do it in the reverse order to the deployment -->

                         

                          <!-- undeploy wars and ears -->

       

                         <!-- Remove the modeshape repository -->

                          <execution>

                              <id>remove-repository</id>

                              <phase>clean</phase>

                              <goals>

                                  <goal>execute-commands</goal>

                              </goals>

                              <configuration>

                                  <execute-commands>

                                      <commands>

                                          <command>/subsystem=modeshape/repository=cpf4:remove</command>

                                      </commands>

                                  </execute-commands>

                                  <hostname>${jboss.hostname}</hostname>

                                  <port>${jboss.adminport}</port>

                                  <username>${jboss.adminuser}</username>

                                  <password>${jboss.adminpasswd}</password>

                              </configuration>

                          </execution>

                         

                          <!-- Remove the modeshape cache we were using -->

                          <execution>

                              <id>remove-cache</id>

                              <phase>clean</phase>

                              <goals>

                                  <goal>execute-commands</goal>

                              </goals>

                              <configuration>

                                  <execute-commands>

                                      <commands>

                                          <command>/subsystem=infinispan/cache-container=cpf4-modeshape/local-cache=cpf4:remove</command>

                                      </commands>

                                  </execute-commands>

                                  <hostname>${jboss.hostname}</hostname>

                                  <port>${jboss.adminport}</port>

                                  <username>${jboss.adminuser}</username>

                                  <password>${jboss.adminpasswd}</password>

                              </configuration>

                          </execution>

                         

                          <!-- Remove the modeshape cache container we were using -->

                          <execution>

                              <id>remove-cache-container</id>

                              <phase>clean</phase>

                              <goals>

                                  <goal>execute-commands</goal>

                              </goals>

                              <configuration>

                                  <execute-commands>

                                      <commands>

                                          <command>/subsystem=infinispan/cache-container=cpf4-modeshape:remove</command>

                                      </commands>

                                  </execute-commands>

                                  <hostname>${jboss.hostname}</hostname>

                                  <port>${jboss.adminport}</port>

                                  <username>${jboss.adminuser}</username>

                                  <password>${jboss.adminpasswd}</password>

                              </configuration>

                          </execution>

                      </executions>

                  </plugin>

      {code}

       

      When I run "mvn clean" after "mvn install" then I get this error

       

      {code}

      [ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.3.Final:execute-commands (remove-repository) on project deploy: Execution remove-repository of goal org.jboss.as.plugins:jboss-as-maven-plugin:7.3.Final:execute-commands failed: Command '/subsystem=modeshape/repository=cpf4:remove' was unsuccessful. Reason: Operation failed: "JBAS014762: Removing services has lead to unsatisfied dependencies:

      [ERROR] Service jboss.modeshape.cpf4.repository was depended upon by service jboss.modeshape.cpf4.repository.reference-factory

      [ERROR] Service jboss.modeshape.cpf4.data was depended upon by service jboss.modeshape.cpf4.indexes, service jboss.modeshape.cpf4.binaries"

      {code}

       

      If I remove the cache container by hand using the jboss-cli.sh command line

       

      {code}

      ../../bin/jboss-cli.sh

      You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.

      [discommected /] connect

      [standalone@localhost:9999 /] /subsystem=infinispan/cache-container=cpf4-modeshape:remove

      {code}

       

      then it is removed as expected and there are no errors.

       

      Any suggestions what might be wrong when the remove fails during the "mvn clean"?

        • 1. Re: jboss-as-maven-plugin and repository creation/deletion

          Hi,

           

          there is the possibility to write a CLI script (with all commands that you want to run) and the plugin jboss-as-maven-plugin will execute the CLI commands from the script. you can look on these both links:

           

          run cli script from maven

          http://blog.akquinet.de/2013/03/04/configuration-of-the-eap6-jboss-as7-with-cli-scripts/

           

          how to create a cli script

          https://docs.jboss.org/author/display/AS71/CLI+Recipes#CLIRecipes-ScriptedConfiguration

           

          I hope this helps.

           

          Regards,

           

          Radouane

          • 2. Re: jboss-as-maven-plugin and repository creation/deletion
            bwallis42

            I've just being having a play with the remove command by hand

             

            {code}

            [standalone@localhost:9999 /] /subsystem=modeshape/repository=cpf4:remove

            07:59:24,466 INFO  [org.jboss.as.controller] (management-handler-thread - 5) JBAS014774: Service status report

            JBAS014775:    New missing/unsatisfied dependencies:

                  service jboss.modeshape.cpf4.data (missing) dependents: [service jboss.modeshape.cpf4.binaries, service jboss.modeshape.cpf4.indexes]

                  service jboss.modeshape.cpf4.repository (missing) dependents: [service jboss.modeshape.cpf4.repository.reference-factory]

             

             

            {

                "outcome" => "failed",

                "failure-description" => "JBAS014762: Removing services has lead to unsatisfied dependencies:

            Service jboss.modeshape.cpf4.repository was depended upon by service jboss.modeshape.cpf4.repository.reference-factory

            Service jboss.modeshape.cpf4.data was depended upon by service jboss.modeshape.cpf4.binaries, service jboss.modeshape.cpf4.indexes",

                "rolled-back" => true

            }

            [standalone@localhost:9999 /] /subsystem=modeshape/repository=cpf4:remove

            {"outcome" => "success"}

            [standalone@localhost:9999 /]

            {code}

             

            It also fails he first time but then succeeds on the second attempt.

             

            It looks like the repository needs to be shutdown before it is removed, there seem to be two running services depending on the repository. The first attempt to remove it seems to shut them down and then the second attempt removes the repository.

             

            Any idea if there is a command to shutdown or disable the repository before removal?