GlassFish v3和glassfish-maven插件(Mac) [英] GlassFish v3 and glassfish-maven-plugin (Mac)

查看:105
本文介绍了GlassFish v3和glassfish-maven插件(Mac)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用glassfish-maven插件( https:// maven- glassfish-plugin.dev.java.net/ )与GlassFish v3(我在Mac和使用Eclipse),我似乎无法让我的Web应用程序部署。我不断遇到:


主密码是启动域所必需的。没有控制台,没有提示可能。您应该使用--savemasterpassword = true创建域,或者使用--passwordfile选项提供密码文件。


这是我的POM文件的相关部分。

 < profiles> 
<个人资料>
< id>开发< / id>
<激活>
<属性>
<名称>阶段< /名称>
<值>开发< /值>
< / property>
< / activation>
< build>
< plugins>
< plugin>
< groupId> org.glassfish.maven.plugin< / groupId>
< artifactId> maven-glassfish-plugin< / artifactId>
< version> 2.2-SNAPSHOT< / version>
<配置>
< glassfishDirectory> $ {glassfish.directory}< / glassfishDirectory>
< user> $ {glassfish.user}< / user>
< passFile> $ {glassfish.directory} / domains / $ {project.artifactId} / config / domain-passwords< / passFile>
< domain>
<名称> $ {project.artifactId}< / name>
< / domain>
<组件>
< component>
<名称> $ {project.artifactId}< / name>
< artifact> $ {project.build.directory} / artifacts / $ {project.artifactId} .war< / artifact>
< / component>
< /组件>
< / configuration>
< / plugin>
< / plugins>
< / build>
< pluginRepositories>
< pluginRepository>
< id>海洋< / id>
< url> http://maven.ocean.net.au/snapshot< / url>
<发布>
<启用> false< / enabled>
< updatePolicy>永不< / updatePolicy>
< / releases>
<快照>
< enabled> true< / enabled>
< updatePolicy>始终< / updatePolicy>
< / snapshots>
< / pluginRepository>
< / pluginRepositories>
< / profile>
< / profiles>

以下是Maven执行的开始域命令。


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

--passwordfile使用临时文件,所以我猜这就是问题所在。出于某种原因,passFile参数不起作用。



有什么想法?我错了,我的假设是什么?

解决方案

完整配置示例,确实引用了< ; passFile> 元素,但各种目标的文档没有提及此元素,而是参考< passwordFile> a href =https://maven-glassfish-plugin.dev.java.net/start-domain-mojo.html =nofollow noreferrer> glassfish:启动域或 glassfish:deploy )。因此,请尝试更新您的个人资料中的插件配置:

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

另外,我建议使用 maven-embedded-glassfish-plugin ,它允许Glassfish在单个JVM中使用其嵌入式API 。非常好。有关更多详细信息,请参见使用适用于v3 embedded glassfish的maven插件



更新:我做了一些进一步的测试,实际上无法在我的机器上重现您的问题(叹气)。首先,我通过执行以下命令(来自< glassfish_home> / bin )创建了一个新的域: $ b <

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


 

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

更新了新创建的webapp的 pom.xml 如下所示:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns :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\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> com.mycompany.app< / groupId>
< artifactId> maven-glassfish-testcase< / artifactId>
<包装>战争< / packaging>
< version> 1.0-SNAPSHOT< / version>
< name> maven-glassfish-testcase Maven Webapp< / name>
< url> http://maven.apache.org< / url>
<属性>
< glassfish.home> / home / pascal / opt / glassfishv3 / glassfish< /glassfish.home>
< domain.username> admin< / domain.username>
< / properties>
< pluginRepositories>
< pluginRepository>
< id>海洋< / id>
< url> http://maven.ocean.net.au/snapshot< / url>
<发布>
<启用> false< / enabled>
< updatePolicy>永不< / updatePolicy>
< / releases>
<快照>
< enabled> true< / enabled>
< updatePolicy>始终< / updatePolicy>
< / snapshots>
< / pluginRepository>
< / pluginRepositories>
<依赖关系>
< dependency>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 3.8.1< / version>
< scope> test< / scope>
< /依赖关系>
< /依赖关系>
< build>
< finalName> maven-glassfish-testcase< / finalName>
< plugins>
< plugin>
< groupId> org.glassfish.maven.plugin< / groupId>
< artifactId> maven-glassfish-plugin< / artifactId>
< version> 2.2-SNAPSHOT< / version>
<配置>
< glassfishDirectory> $ {glassfish.home}< / glassfishDirectory>
< user> $ {domain.username}< / user>
< passwordFile> $ {glassfish.home} / domains / $ {project.artifactId} / master-password< / passwordFile>
< debug> true< / debug>
< echo> true< / echo>
< domain>
<名称> $ {project.artifactId}< / name>
< adminPort> 4848< / adminPort> <! - mvn glassfish的必需项目:deploy - >
< / domain>
<组件>
< component>
<名称> $ {project.artifactId}< / name>
< artifact> $ {project.build.directory} / $ {project.build.finalName} .war< / artifact>
< / component>
< /组件>
< / configuration>
< / plugin>
< / plugins>
< / build>
< / project>

使用此设置,运行 mvn glassfish:start-domain 产生以下输出:

 
$ mvn glassfish:start-domain
[信息]扫描项目...
[INFO] snapshot org.glassfish.maven.plugin:maven-glassfish-plugin:2.2-SNAPSHOT:检查来自海洋的更新
[INFO] ------------ -------------------------------------------------- ----------
[INFO]构建maven-glassfish-testcase Maven Webapp
[信息]任务段:[glassfish:start-domain]
[信息] -------------------------------------------------- ----------------------
[INFO] [glassfish:start-domain {execution:default-cli}]
[信息] 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 --upgragra de = false --verbose = false maven-glassfish-testcase
[INFO]已启动域名:maven-glassfish-testcase
[信息]域名位置:/ home / pascal / opt / glassfishv3 / glassfish / domains / maven-glassfish-testcase
[INFO]日志文件:/home/pascal/opt/glassfishv3/glassfish/domains/maven-glassfish-testcase/logs/server.log
[INFO] Admin port for域:4848
[INFO]域的调试端口:9009
[INFO] ------------------------- -----------------------------------------------
[信息]建立成功
[信息] ------------------------------------- -----------------------------------
[信息]总时间:27秒
[INFO]完成时间:星期一Dec 21 20:16:17 CET 2009
[INFO]最终记忆:4M / 53M
[信息] ------------- -------------------------------------------------- ---------

如您所见, - passwordfile 选项。换句话说,事情按预期工作。也许尝试用密码文件的硬编码路径来调试此设置,它应该只是工作!

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</url>
                <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?

解决方案

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">
  <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</url>
  <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</url>
      <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!

这篇关于GlassFish v3和glassfish-maven插件(Mac)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆