views:

91

answers:

2

I need my JavaEE-application to be deployed on Glassfish as a directory, not a packaged WAR file. Is it possible to deploy a directory to Glassfish with the Maven Glassfish Plugin?

With the admin console, it's possible. But i want to be also able to do it on the command line.

A: 

I did not get it to work with the maven plugin, but it is possible to deploy to glassfish from the command line using the asadmin command from the glassfish/bin directory:

asadmin deploy --contextroot context_root path_to_ear_or_directory

Jörn Horstmann
Thats not an option for me because i pass a lot of parameters to Glassfish from within my Maven build. Anyway, thanks
ifischer
+1  A: 

The following configuration works for me (note that the artifact element points to a directory):

<plugin>  
  <groupId>org.glassfish.maven.plugin</groupId>
  <artifactId>maven-glassfish-plugin</artifactId>
  <version>2.2-SNAPSHOT</version> 
  <configuration>                           
    <glassfishDirectory>${glassfish.home}</glassfishDirectory>
    <user>${domain.username}</user>                   
    <passwordFile>${glassfish.home}/domains/${project.artifactId}/master-password</passwordFile>                                                
    <autoCreate>true</autoCreate>
    <debug>true</debug>                                                   
    <echo>true</echo>
    <skip>${test.int.skip}</skip>
    <domain>
      <name>${project.artifactId}</name>
      <httpPort>8080</httpPort>
      <adminPort>4848</adminPort>
    </domain>           
    <components>
      <component>                 
        <name>${project.artifactId}</name>
        <artifact>${project.build.directory}/${project.build.finalName}</artifact>
      </component>
    </components>                                         
  </configuration>
</plugin> 

The resulting asadmin command is:

asadmin --host localhost --port 4848 --user admin --passwordfile /home/pascal/opt
/glassfishv3/glassfish/domains/maven-glassfish-testcase/master-password --interac
tive=false --echo=true --terse=true deploy --name maven-glassfish-testcase --forc
e=false --precompilejsp=false --verify=false --enabled=true --generatermistubs=fa
lse --availabilityenabled=false --keepreposdir=false --keepfailedstubs=false --lo
gReportedErrors=true --upload=false --help=false /home/pascal/Projects/stackoverf
low/maven-glassfish-testcase/target/maven-glassfish-testcase
Pascal Thivent
So easy... i should have tried it before. Thanks!Changed my pom.xml accordingly. It works and now i'm running 'mvn war:exploded glassfish:redeploy'.
ifischer
@ifischer: Isn't it? :) Actually, I tried it specially for you.
Pascal Thivent