jboss-as-maven-plugin and repository creation/deletion
bwallis42 Mar 14, 2013 7:26 AMHas 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"?