jbossas / jboss-as-maven-plugin

Maven plugin to deploy applications to JBoss AS 7 (moved to https://github.com/wildfly/wildfly-maven-plugin)
74 stars 69 forks source link

Can't make beforeDeployment work in jboss-as:run #51

Closed agoncal closed 11 years ago

agoncal commented 11 years ago

Hi,

I'm trying to start a JBoss, configure it, deploy and application, and then hold the server up and running (something like jetty:run so developpers can quickly run an application). So for that I'm using mvn jboss-as:run with the 'beforeDeployment' element. It looks like this :

        <plugin>
            <!--To run the app with JBoss : jboss-as:run -->
            <groupId>org.jboss.as.plugins</groupId>
            <artifactId>jboss-as-maven-plugin</artifactId>
            <version>7.4.Final</version>
            <executions>
                <execution>
                    <id>run-app</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <jvm-args>-Xms512M -Xmx1303M -XX:MaxPermSize=256M -Duser.country=EN -Duser.language=en</jvm-args>
                        <beforeDeployment>
                            <execute-commands>
                            <commands>
                                <command>/subsystem=datasources/data-source=CelerioDS:add(connection-url="jdbc:h2:mem:CelerioDS", jndi-name=java:jboss/datasources/CelerioDS, driver-name=h2, user-name=sa, password=sa)</command>
                                <command>/subsystem=datasources/data-source=CelerioDS:enable</command>
                                <command>/subsystem=logging/logger=fr.bdf.celerio:add(level=DEBUG)</command>
                            </commands>
                            </execute-commands>
                        </beforeDeployment>
                    </configuration>
                </execution>
            </executions>
        </plugin>

This doesn't seem to work because the plugin starts JBoss, deploys the application and then complains that the DataSource is not available. I could find any example nor test case for this (https://github.com/jbossas/jboss-as-maven-plugin/tree/master/src/test/resources/unit/common).

And what I really would like is to execute a script before deployment. Looking at the code, this looks possible (https://github.com/jbossas/jboss-as-maven-plugin/blob/master/src/main/java/org/jboss/as/plugin/cli/Commands.java#L118) but again, I could make it work.

        <scripts>
            <script>src/main/config/jbossConfigSetup.cli</script>
        </scripts>
akram commented 11 years ago

We should use this instead: add a phase and commands must be set under directly, not in

<plugin>
            <!--To run the app with JBoss : jboss-as:run -->
            <groupId>org.jboss.as.plugins</groupId>
            <artifactId>jboss-as-maven-plugin</artifactId>
            <version>7.4.Final</version>
            <executions>
                <execution>
                    <id>run-app</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                   <phase>package</phase>
                    <configuration>
                        <jvm-args>-Xms512M -Xmx1303M -XX:MaxPermSize=256M -Duser.country=EN -Duser.language=en</jvm-args>
                        <beforeDeployment>
                            <commands>
                                <command>/subsystem=datasources/data-source=CelerioDS:add(connection-url="jdbc:h2:mem:CelerioDS", jndi-name=java:jboss/datasources/CelerioDS, driver-name=h2, user-name=sa, password=sa)</command>
                                <command>/subsystem=datasources/data-source=CelerioDS:enable</command>
                                <command>/subsystem=logging/logger=fr.bdf.celerio:add(level=DEBUG)</command>
                            </commands>
                        </beforeDeployment>
                    </configuration>
                </execution>
            </executions>
        </plugin>
jamezp commented 11 years ago

Closing this as I've been neglecting the issues here. If it's still an issue please reopen.