Mirea Vasile
Mirea Vasile

Reputation: 421

maven-embedded-glassfish-plugin deploying 2 applications

I have the following use-case: I am having a web-application implemented with Spring MVC using a Web service implemented with Spring WS.

The projects are using maven as build tool. Now I want to implement integration test for the web-application. For this I want to use the maven-embedded-glassfish-plugin. I have the following maven configuration in pom.xml:

    <plugin>
    <groupId>org.glassfish</groupId>
    <artifactId>maven-embedded-glassfish-plugin</artifactId>
        <version>3.1.1</version>
        <configuration>
           <goalPrefix>embedded-glassfish</goalPrefix>
           <app>${basedir}/target/web-app.war</app>

           <autoDelete>true</autoDelete>
           <port>8080</port>
           <name>web-app</name>

           <configFile>src/test/resources/glassfish/domain.xml</configFile>
        </configuration>

        <executions>
           <execution>
              <id>start-glassfish</id>
              <phase>pre-integration-test</phase>
              <goals>
                 <goal>start</goal>
              </goals>
           </execution>
           <execution>
              <id>glassfish-deploy</id>
              <phase>pre-integration-test</phase>
              <goals>
                 <goal>deploy</goal>
              </goals>
           </execution>
           <execution>
              <id>glassfish-undeploy</id>
              <phase>post-integration-test</phase>
              <goals>
                 <goal>undeploy</goal>
              </goals>
           </execution>
           <execution>
              <id>stop-glassfish</id>
              <phase>post-integration-test</phase>
              <goals>
                 <goal>stop</goal>
              </goals>
           </execution>
        </executions>
      </plugin> 

Everything works fine. But now I need to add the deployment of the webservice.war file. This is not a dependency of my pom in this moment. I am having only a stub class for calling the web service defined in the web-app.war application.

So any good solution how to deploy this second application ?

I would like to be something automatically, maybe using the maven repository for it, cause if I make a modification I want to use automatically the new version of the web-service.

Upvotes: 3

Views: 2678

Answers (2)

husnu
husnu

Reputation: 313

For 3.1.1 version of the maven-embedded-glassfish-plugin, you just need to set the "glassfish.embedded.tmpdir" property to a static value (for windows os, but I'm not sure for linux). Because maven can't convert the paths.

I'm deploying an ear to glassfish and it perfectly working for me.

My configuration is:

    <plugin>
            <groupId>org.glassfish</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <systemProperties>
                    <property>glassfish.embedded.tmpdir=target/glassfish</property>
                </systemProperties>
                <app>${project.build.directory}/${build.finalName}.ear</app>
                <autoDelete>true</autoDelete>
                <port>8080</port>
                <contextRoot>test</contextRoot>
            </configuration>
            <executions>
                <execution>
                    <id>start-glassfish</id>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

But it is really interesting if I remove the <property>glassfish.embedded.tmpdir=target/glassfish</property>

part and then start the server, it is loading the project slowly and it is not stable.

Upvotes: 0

Mirea Vasile
Mirea Vasile

Reputation: 421

I find out with the help of [email protected] and Mister Bhavani Shankar the following solution:

  <execution>
      <id>glassfish-additional_deployments</id>
      <phase>pre-integration-test</phase>
      <goals>
       <goal>admin</goal>
      </goals>
      <configuration>
        <commands>
          <param>deploy ${basedir}/src/test/resources/integrationtest/app-ws.war</param>
        </commands>
      </configuration>
  </execution>

Teoretically you can set the dependency in maven of the war and then deploy the war file from the lib directory too.

Something interesting about this plugin, if somebody want to use the option :

    <instanceRoot>${project.build.directory}/glassfish</instanceRoot>

Is not working in the version 3.1.1 only with an existing glassfish installation. If you want to set this property then use (without having an installation of glassfish):

      <systemProperties>
        <property>glassfish.embedded.tmpdir=target/glassfish</property>
      </systemProperties>

Upvotes: 4

Related Questions