ant*_*tor 7 java maven-2 glassfish maven
我正在尝试使用glassfish-maven-plugin(https://maven-glassfish-plugin.dev.java.net/)与GlassFish v3(我在Mac上并使用Eclipse),我似乎无法让我的Web应用程序部署.我一直遇到:
启动域需要主密码.没有控制台,没有提示可能.您应该使用--savemasterpassword = true创建域,或者使用--passwordfile选项提供密码文件.
这是我的POM文件的相关部分.
<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>
Run Code Online (Sandbox Code Playgroud)
这是Maven正在执行的start-domain命令.
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参数不起作用.
有任何想法吗?我的假设错了吗?
Pas*_*ent 11
在相当完整的配置示例中,确实存在对该<passFile>元素的引用,但是各种目标的文档没有提及该元素<passwordFile>而是引用(参见例如glassfish:start-domain或glassfish:deploy).因此,请尝试相应地更新配置文件中插件的配置:
<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>
Run Code Online (Sandbox Code Playgroud)
作为旁注,我推荐使用maven-embedded-glassfish-plugin,它允许使用其嵌入式API在单个JVM中运行Glassfish.非常好.有关更多详细信息,请参阅使用maven插件获取v3嵌入式glassfish.
更新:我做了一些进一步的测试,实际上无法在我的机器上重现你的问题(叹气).
首先,我通过执行以下命令(from <glassfish_home>/bin)创建了一个新域:
$ ./asadmin create-domain --savemasterpassword=true maven-glassfish-testcase
Run Code Online (Sandbox Code Playgroud)
然后,我使用maven的webapp原型创建了一个新的webapp:
$ mvn archetype:create -DgroupId=com.mycompany.app \
-DartifactId=maven-glassfish-testcase \
-DarchetypeArtifactId=maven-archetype-webapp
Run Code Online (Sandbox Code Playgroud)
并更新了pom.xml新创建的webapp,如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
使用此设置,running将mvn glassfish:start-domain生成以下输出:
$ 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] ------------------------------------------------------------------------
如您所见,--passwordfile使用POM中指定的文件正确传递该选项.换句话说,事情按预期工作.也许尝试使用密码文件的硬编码路径来调试此设置,它应该工作!