views:

2218

answers:

2

I'm trying to use the glassfish-maven-plugin (https://maven-glassfish-plugin.dev.java.net/) with GlassFish v3 (I'm on a Mac and using Eclipse) and I can't seem to get my web app to deploy. I keep running into:

The Master Password is required to start the domain. No console, no prompting possible. You should either create the domain with --savemasterpassword=true or provide a password file with the --passwordfile option.

Here is the relevant portion of my POM file.

<profiles>
 <profile>
  <id>development</id>
  <activation>
   <property>
    <name>phase</name>
    <value>development</value>
   </property>
  </activation>
  <build>
   <plugins>
    <plugin>
     <groupId>org.glassfish.maven.plugin</groupId>
     <artifactId>maven-glassfish-plugin</artifactId>
     <version>2.2-SNAPSHOT</version>
     <configuration>
      <glassfishDirectory>${glassfish.directory}</glassfishDirectory>
      <user>${glassfish.user}</user>
      <passFile>${glassfish.directory}/domains/${project.artifactId}/config/domain-passwords</passFile>
      <domain>
       <name>${project.artifactId}</name>
      </domain>
      <components>
       <component>
        <name>${project.artifactId}</name>
        <artifact>${project.build.directory}/artifacts/${project.artifactId}.war</artifact>
       </component>
      </components>
     </configuration>
    </plugin>
   </plugins>
  </build>
  <pluginRepositories>
   <pluginRepository>
    <id>ocean</id>
    <url>http://maven.ocean.net.au/snapshot&lt;/url&gt;
    <releases>
     <enabled>false</enabled>
     <updatePolicy>never</updatePolicy>
    </releases>
    <snapshots>
     <enabled>true</enabled>
     <updatePolicy>always</updatePolicy>
    </snapshots>
   </pluginRepository>
  </pluginRepositories>
 </profile>
</profiles>

Here is the start-domain command Maven is executing.

asadmin --host localhost --port 4848 --user admin --passwordfile /var/folders/sk/skcc8rAVGSynOBBaOwWN3U+++TI/-Tmp-/mgfp5377058868244877698.tmp --interactive=false --echo=true --terse=true start-domain --debug=false --domaindir /Applications/GlassFish/v3/glassfish/domains --help=false --upgrade=false --verbose=false mvnrepo

The --passwordfile is using a temp file so I'm guessing that is the problem. For some reason the passFile parameter isn't working.

Any ideas? I'm I wrong with my assumption?

+5  A: 

In the Fairly Complete Configuration Example, there is indeed a reference to the <passFile> element but the documentation of the various goals doesn't mention this element and refer to <passwordFile> instead (see for example glassfish:start-domain or glassfish:deploy). So, try to update the configuration of your plugin in your profile accordingly:

<plugin>
  <groupId>org.glassfish.maven.plugin</groupId>
  <artifactId>maven-glassfish-plugin</artifactId>
  <version>2.2-SNAPSHOT</version>
  <configuration>
    <glassfishDirectory>${glassfish.directory}</glassfishDirectory>
    <user>${glassfish.user}</user>
    <passwordFile>${glassfish.directory}/domains/${project.artifactId}/config/domain-passwords</passwordFile>
    <domain>
      <name>${project.artifactId}</name>
    </domain>
    <components>
      <component>
        <name>${project.artifactId}</name>
        <artifact>${project.build.directory}/artifacts/${project.artifactId}.war</artifact>
      </component>
    </components>
  </configuration>
</plugin>

As a side note, I recommend the maven-embedded-glassfish-plugin which allows to run Glassfish in a single JVM using its embedded API. Very nice. See Using maven plugin for v3 embedded glassfish for more details.

UPDATE: I did some further testing and, couldn't actually reproduce your problem on my machine (sigh).

First, I created a new domain by executing the following command (from <glassfish_home>/bin):

$ ./asadmin create-domain  --savemasterpassword=true maven-glassfish-testcase

Then, I created a new webapp using maven's webapp archetype:

$ mvn archetype:create -DgroupId=com.mycompany.app \
      -DartifactId=maven-glassfish-testcase \
      -DarchetypeArtifactId=maven-archetype-webapp

And updated the pom.xml of the freshly created webapp as follow:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>maven-glassfish-testcase</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>maven-glassfish-testcase Maven Webapp</name>
  <url>http://maven.apache.org&lt;/url&gt;
  <properties>
    <glassfish.home>/home/pascal/opt/glassfishv3/glassfish</glassfish.home>
    <domain.username>admin</domain.username>
  </properties>
  <pluginRepositories>
    <pluginRepository>
      <id>ocean</id>
      <url>http://maven.ocean.net.au/snapshot&lt;/url&gt;
      <releases>
        <enabled>false</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>maven-glassfish-testcase</finalName>
    <plugins>
      <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>
          <debug>true</debug>
          <echo>true</echo>
          <domain>
            <name>${project.artifactId}</name>
            <adminPort>4848</adminPort> <!-- mandatory for mvn glassfish:deploy -->
          </domain>
          <components>
            <component>
              <name>${project.artifactId}</name>
              <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
            </component>
          </components>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

With this setup, running mvn glassfish:start-domain produces the following output:

$ mvn glassfish:start-domain
[INFO] Scanning for projects...
[INFO] snapshot org.glassfish.maven.plugin:maven-glassfish-plugin:2.2-SNAPSHOT: checking for updates from ocean
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-glassfish-testcase Maven Webapp
[INFO]    task-segment: [glassfish:start-domain]
[INFO] ------------------------------------------------------------------------
[INFO] [glassfish:start-domain {execution: default-cli}]
[INFO] asadmin --host localhost --port 4848 --user admin --passwordfile /home/pascal/opt/glassfishv3/glassfish/domains/maven-glassfish-testcase/master-password --interactive=false --echo=true --terse=true start-domain --debug=true --domaindir /home/pascal/opt/glassfishv3/glassfish/domains --help=false --upgrade=false --verbose=false maven-glassfish-testcase
[INFO] Started domain: maven-glassfish-testcase
[INFO] Domain location: /home/pascal/opt/glassfishv3/glassfish/domains/maven-glassfish-testcase
[INFO] Log file: /home/pascal/opt/glassfishv3/glassfish/domains/maven-glassfish-testcase/logs/server.log
[INFO] Admin port for the domain: 4848
[INFO] Debug port for the domain: 9009
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27 seconds
[INFO] Finished at: Mon Dec 21 20:16:17 CET 2009
[INFO] Final Memory: 4M/53M
[INFO] ------------------------------------------------------------------------

As you can see, the --passwordfile option is passed correctly using the file specified in the POM. In other words, things are working as expected. Maybe try with an hard coded path to the password file to debug this setting, it should just work!

Pascal Thivent
That's correct. The documentation does refer to passFile. I tried passwordFile and didn't have any luck. I'll try the plugin you mentioned.
sticksnleaves
I was able to get the maven-embedded-glassfish-plugin working. This will do what I need.
sticksnleaves
A: 

It just took me a while to realize that i accidentally left the "adminPassword" property in the Maven-Glassfish-Plugin Configuration (so i had both adminPassword and passwordFile set). The plugin still used the temporary passwordfile instead of my own one, resulting in the above error.

Just in case someone else is as stupid as me ;)

ifischer