Desperately need help with Glassfish 3.1 deployment and issues running in Maven
I am trying desperately to get a maven maven-glassfish-plugin working to start my domain and deploy a war so I can test. I wanted to use maven-glassfish-plugin because as far as I can find, maven-embedded-glassfish-plugin does not support setting a keyfile so I can test login authentication through selenium
${project.build.outputDirectory}/keyfile
But I cannot get maven-glassfish-plugin to run, and I cannot get maven-embedded-glassfish-plugin to actually allow programmatic setting of users and authentication.
My Maven items:
<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>
But I still cannot get this to start the admin without forcing the admin login.
I started blogging about this, but really with there was a solution
=== Details ===
I went through much different iteration with this plugin, and really did not have complete success. One issue that keeps plaguing this plugin in my testing, is when the plugin defines no username and password, or adds the default admin username and password like:
<user>${glassfish.adminUser}</user>
<adminPassword>${glassfish.adminPassword}</adminPassword>
The domain will not start based on a missing “Master Password” and also a warning about deprecated syntax.
[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".
Another option was to use a passwordFile for the startup
<passwordFile>${glassfish.passwordFile}</passwordFile>
…
<glassfish.passwordFile>${project.build.testOutputDirectory}/passwd.local.file</glassfish.passwordFile>
When I attempt to start the domain
mvn org.glassfish.maven.plugin:maven-glassfish-plugin:start-domain -e –X
The domain successfully starts as per the logs:
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
The domain successfully starts as per the logs:
[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.....
Even though this seemed to complete successfully, there was a fundamen开发者_如何学Ctal issue I could not solve. When this method to start domain1 in GF, there is not a default admin login, thus you are prompted for an admin login:
The admin screen does not get a user to login with as confirmed in the logs:
[#|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|#]
When attempting to actually login, admin user does not have administration permission as found in the logs:
[#|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|#]
My application is also not actually deployed when this happens. So I rally have access to nothing.
I also tried to remove the passwordFile, and use nothing, or use just the user, or even the user and adminPassword, but still no luck
My contents of my passwordFile:
AS_ADMIN_MASTERPASSWORD=changeit
AS_ADMIN_PASSWORD=adminadmin
AS_ADMIN_USERPASSWORD=xxx
When I run this same command on outside of 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
I get the same issues where I cannot seem to get into my control panel, but the server logs are being populated now.
I've been having similar issues. I ended up giving up and using regular embedded glassfish, rather than the maven plugin. This may be unsuitable for a test environment.
Even in embedded glassfish it doesn't seem to be possible to create users, because the create-file-user command doesn't accept a --userpassword option anymore, and the CommandRunner doesn't understand --passwordfile .
One gets the impression that embedded glassfish is less than widely used and tested :S
See: http://java.net/jira/browse/GLASSFISH-16277 See: glassfish-embedded-maven-plugin - how to deploy resources
I had a similar issue and found this solution. You need to create a new domain with a password-file. So no authenification is required.
http://codingbone.wordpress.com/2011/03/07/continuous-deployment-deploying-to-glassfish-with-maven-and-teamcity/ in short:
cd ${glassfish.home}/bin ./asadmin create-domain --savemasterpassword=true my-apps
On the on the host machine I’ve created/appended the file ~/.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>
In the project pom.xml, we define a profile for glassfish deployment:
<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>
You can use the default password "changeit", as written here http://amanica.blogspot.de/2009/07/get-rid-of-glassfish-master-password.html .
Change the pom.xml like this:
<user>admin</user>
<adminPassword>changeit</adminPassword>
and it will deploy your project to glassfish.
精彩评论