我正在拼命地尝试让一个maven maven-glassfish-plugin启动我的域并部署一个war,这样我就可以测试了。我想使用maven-glassfish-plugin,因为据我所知,maven-embedded glassfish-plugin不支持设置密钥文件,所以我可以通过selenium测试登录身份验证
${project.build.outputDirectory}/keyfile
但是我不能让maven-glassfish-plugin运行,我也不能让maven-embedded-glassfish-plugin真正允许用户和身份验证的程序化设置。
我的Maven项目:
<properties>
<glassfish.home>C:/usr/bin/glassfish-3.1-b42-02_11_2011/</glassfish.home>
<glassfish.domain.name>domain1</glassfish.domain.name>
<glassfish.domain.host>localhost</glassfish.domain.host>
<!-- Glassfish -->
<glassfish.version>3.2-SNAPSHOT</glassfish.version>
<glassfish.plugin.version>2.1</glassfish.plugin.version>
<glassfish.domain.name>domain1</glassfish.domain.name>
<glassfish.domain.host>localhost</glassfish.domain.host>
<glassfish.adminUser>admin</glassfish.adminUser>
<glassfish.adminPassword>adminadmin</glassfish.adminPassword>
<glassfish.passwordFile>${project.build.testOutputDirectory}/passwd.local.file</glassfish.passwordFile>-->
...
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>${glassfish.plugin.version}</version>
<configuration>
<glassfishDirectory>${glassfish.home}</glassfishDirectory>
<user>${glassfish.adminUser}</user>
<!--<adminPassword></adminPassword>-->
<passwordFile>${glassfish.passwordFile}</passwordFile>
<autoCreate>true</autoCreate>
<debug>true</debug>
<echo>true</echo>
<terse>false</terse>
<domain>
<name>${glassfish.domain.name}</name>
<host>${glassfish.domain.host}</host>
<adminPort>4848</adminPort>
<httpPort>8080</httpPort>
<httpsPort>8443</httpsPort>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
</component>
</components>
</configuration>
</plugin>但是我仍然无法在不强制管理员登录的情况下启动管理员。
我开始在博客上讨论这件事,但实际上有一个解决方案
===详细信息===
我用这个插件经历了很多不同的迭代,真的没有完全成功。在我的测试中,有一个问题一直困扰着这个插件,那就是插件没有定义用户名和密码,或者添加了默认的管理员用户名和密码,比如:
<user>${glassfish.adminUser}</user>
<adminPassword>${glassfish.adminPassword}</adminPassword>域将不会基于缺少的“Master Password”和有关弃用语法的警告而启动。
[DEBUG] [C:\usr\bin\glassfish-3.1-b42-02_11_2011\bin\asadmin.bat, start-domain, --echo=true, --terse=false, --interactive=false, --user, admin, --passwordfile, C:\DOCUME~1\MKN
UTS~1\LOCALS~1\Temp\mgfp2524993691695672772.tmp, --debug=true, --domaindir, C:\usr\bin\glassfish-3.1-b42-02_11_2011\domains, domain1]
[INFO] Deprecated syntax, instead use:
[INFO] asadmin --echo --terse=false --interactive=false --user admin --passwordfile C:\DOCUME~1\MKNUTS~1\LOCALS~1\Temp\mgfp2524993691695672772.tmp start-domain [options] ...
[INFO] asadmin --host localhost --port 4848 --user admin --passwordfile C:\DOCUME~1\MKNUTS~1\LOCALS~1\Temp\mgfp2524993691695672772.tmp --interactive=false --echo=true --terse=false start-domain --verbose=false --upgrade=false --debug=true --domaindir "C:\\usr\\bin\\glassfish-3.1-b42-02_11_2011\\domains" domain1
[INFO] Command start-domain failed.
[ERROR] 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.
[ERROR] Unable to start domain "domain1".
[ERROR] For more detail on what might be causing the problem try running maven with the --debug option
[ERROR] or setting the maven-glassfish-plugin "echo" property to "true".另一种选择是使用passwordFile进行启动
<passwordFile>${glassfish.passwordFile}</passwordFile>
…
<glassfish.passwordFile>${project.build.testOutputDirectory}/passwd.local.file</glassfish.passwordFile>当我尝试启动域时
mvn org.glassfish.maven.plugin:maven-glassfish-plugin:start-domain -e –X根据日志,域名启动成功:
asadmin --host localhost --port 4848 --user admin --passwordfile C:\DOCUME~1\MKNUTS~1\LOCALS~1\Temp\mgfp2524993691695672772.tmp --interactive=false --echo=true --terse=false start-domain --verbose=false --upgrade=false --debug=true --domaindir "C:\\usr\\bin\\glassfish-3.1-b42-02_11_2011\\domains" domain1根据日志,域名启动成功:
[DEBUG] [C:\usr\bin\glassfish-3.1-b42-02_11_2011\bin\asadmin.bat, start-domain, --echo=true, --terse=false, --interactive=false, --user, MKnuts6173c, --passwordfile, C:\usr\SY
NCH\PACKT\3166\Chapters_Code\ch03\target\test-classes/passwd.local.file, --debug=true, --domaindir, C:\usr\bin\glassfish-3.1-b42-02_11_2011\domains, domain1]
[INFO] Deprecated syntax, instead use:
[INFO] asadmin --echo --terse=false --interactive=false --user MKnuts6173c –passwordfile C:\usr\SYNCH\PACKT\3166\Chapters_Code\ch03\target\test-classes/passwd.local.file start-domain [options] ...
[INFO] asadmin --host localhost --port 4848 --user MKnuts6173c --passwordfile C:\usr\SYNCH\PACKT\3166\Chapters_Code\ch03\target\test-classes/passwd.local.file --interactive=false --echo=true --terse=false start-domain --verbose=false --upgrade=false --debug=true --domaindir "C:\\usr\\bin\\glassfish-3.1-b42-02_11_2011\\domains" domain1
[INFO] Attempting to start domain1.... Please look at the server log for more details.....尽管这似乎成功地完成了,但有一个根本的问题我无法解决。当此方法在GF中启动domain1时,没有默认的管理员登录,因此系统会提示您输入管理员登录:

管理员屏幕不能让用户登录,这在日志中得到确认:
[#|2011-02-15T15:15:21.047-0500|INFO|glassfish3.1|javax.enterprise.system.tools.admin.com.sun.enterprise.container.common|_ThreadID=100;_ThreadName=Thread-1;|User [] from host localhost does not have administration access|#]尝试实际登录时,admin用户不具有日志中的管理权限:
[#|2011-02-15T15:23:22.535-0500|INFO|glassfish3.1|javax.enterprise.system.tools.admin.com.sun.enterprise.container.common|_ThreadID=118;_ThreadName=Thread-1;|User [admin] from host localhost does not have administration access|#]

当这种情况发生时,我的应用程序实际上也没有部署。所以我什么也得不到。
我还尝试删除passwordFile,不使用任何东西,或者只使用用户,甚至是用户和adminPassword,但仍然没有成功
我的passwordFile的内容:
AS_ADMIN_MASTERPASSWORD=changeit
AS_ADMIN_PASSWORD=adminadmin
AS_ADMIN_USERPASSWORD=xxx当我在maven之外运行同样的命令时。
C:\usr\bin\glassfish-3.1-b42-02_11_2011\bin\asadmin.bat --host localhost --port 4848 --user MKnuts6173c --passwordfile C:\usr\SYNCH\PACKT\3166\Chapters_Code\ch03\target\test-classes/passwd.local.file --interactive=false --echo=true --terse=false start-domain --verbose=false --upgrade=false --debug=true --domaindir "C:\\usr\\bin\\glassfish-3.1-b42-02_11_2011\\domains" domain1我得到了同样的问题,我似乎无法进入我的控制面板,但现在正在填充服务器日志。
发布于 2012-03-19 17:50:40
我遇到了类似的问题,并找到了这个解决方案。您需要使用密码文件创建一个新域。所以不需要身份验证。
http://codingbone.wordpress.com/2011/03/07/continuous-deployment-deploying-to-glassfish-with-maven-and-teamcity/简而言之:
cd ${glassfish.home}/bin ./asadmin create-domain --savemasterpassword=true my-apps在主机上,我已经创建/附加了文件~/.m2/settings.xml。
<?xml version="1.0" encoding="UTF-8"?>
xmlns="[http://maven.apache.org/SETTINGS/1.0.0"]
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance"]
xsi:schemaLocation="[http://maven.apache.org/SETTINGS/1.0.0] [http://maven.apache.org/xsd/settings-1.0.0.xsd">]
<profiles>
<profile>
<id>glassfish-context</id>
<properties>
<local.glassfish.home>/Users/brass/bin/glassfishv3</local.glassfish.home>
<local.glassfish.user>admin</local.glassfish.user>
<local.glassfish.domain>my-apps</local.glassfish.domain>
<local.glassfish.passfile>${local.glassfish.home}/glassfish/domains/${local.glassfish.domain}/master-password</local.glassfish.passfile>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>glassfish-context</activeProfile>
</activeProfiles>
</settings>在项目pom.xml中,我们为glassfish部署定义了一个配置文件:
<profile>
<id>glassfish-deploy</id>
<pluginRepositories>
<pluginRepository>
<id>maven.java.net</id>
<name>Java.net Maven2 Repository</name>
<url>[http://download.java.net/maven/2</url>]
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<glassfishDirectory>${local.glassfish.home}</glassfishDirectory>
<user>${local.glassfish.user}</user>
<passwordFile>${local.glassfish.passfile}</passwordFile>
<autoCreate>true</autoCreate>
<debug>true</debug>
<echo>false</echo>
<terse>true</terse>
<domain>
<name>${local.glassfish.domain}</name>
<adminPort>4848</adminPort>
<httpPort>8080</httpPort>
<httpsPort>8443</httpsPort>
<iiopPort>3700</iiopPort>
<jmsPort>7676</jmsPort>
<reuse>false</reuse>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
</component>
</components>
</configuration>
</plugin>
</plugins>
</build>
</profile>发布于 2011-03-30 09:06:15
我也遇到过类似的问题。我最终放弃了使用常规的嵌入式glassfish,而不是maven插件。这可能不适合测试环境。
即使在嵌入式glassfish中,似乎也不可能创建用户,因为create-file-user命令不再接受--userpassword选项,并且CommandRunner不理解--passwordfile。
人们得到的印象是,嵌入式glassfish并没有得到广泛的使用和测试:
请参阅:http://java.net/jira/browse/GLASSFISH-16277请参阅:glassfish-embedded-maven-plugin - how to deploy resources
发布于 2013-02-28 22:04:23
您可以使用默认密码"changeit",就像这里写的http://amanica.blogspot.de/2009/07/get-rid-of-glassfish-master-password.html一样。
如下所示更改pom.xml:
<user>admin</user>
<adminPassword>changeit</adminPassword>它会将你的项目部署到glassfish。
https://stackoverflow.com/questions/5009425
复制相似问题