部署hudson時報錯解決方案
啟動hudson後,報如下錯:AWT is not properly configured on this server. Perhaps you need to run your container with "-Djava.awt.headless=true"?
解決方案:
STEP 1: Install Hudson
I used the Tomcat Web Applications Manager to install Hudson, which I downloaded athttp://hudson-ci.org/latest/hudson.war. The version I downloaded was version 1.378; however while I was installing and configuring the server, version 1.379 was released, so I’ll be upgrading a little bit later.
On the Manager screen, toward the bottom you’ll see under the subheading “DEPLOY”, the option to upload a WAR file. Since I’m new to Java applications and don’t have my configuration files prepared, I used the second option, which was to simply upload the WAR file to deploy. The file selector field lets you browse your local drive for the file, which is called hudson.war
STEP 2: Configuring the Java environment variables
After attempting to launch Hudson using the url
AWT is not properly configured on this server. Perhaps
you need to run your container with "-Djava.awt.headless=true"
A quick Google of the error message, plus “Hudson” led me to this post, indicating that I needed to set the following environment variable:
JAVA_OPTS=-Djava.awt.headless=true
Hudson also has a specific environment variable that needs to be configured as well:
HUDSON_HOME=/path/to/hudson/home
This is the directory where Hudson will store its configuration and data files. For an application running under Tomcat launched at server bootup on Snow Leopard Server, this directory needs to belong to _appserver:_appserverusr
,
so chmod this as needed.
Now, I’ve got Tomcat configured to launch as a daemon at server startup, so I’m going to place these environment variables in the LaunchDaemon plist file for Tomcat. You can find this file in/System/Library/LaunchDaemons
,
listed as org.apache.tomcat.plist
. Edit this file and add the following key/string combinations to the <dict>
container
nested inside the <EnvironmentVariables>
container:
<key>HUDSON_HOME</key> <string>/path/to/hudson/home</string> <key>JAVA_OPTS</key> <string>-Djava.awt.headless=true</string>
Save this file.
STEP 3: Modify the character encoding of Tomcat
Snow Leopard Server comes with Tomcat version 6.0.24 preinstalled. By default, Tomcat uses ISO-8859 -1 character encoding for browser URLs. This needs to be changed for Hudson to function properly. This can be changed with a simple modification to the server
configuration file, which is found at /Library/Tomcat/conf/server.xml
.
Edit this file, and change the container that uses port 8080 to add URIEncoding="UTF-8".
Save this file.
STEP 4: Secure Hudson by setting the administration user login/password in the tomcat-users.xml file
Add a rolename of “admin” to the tomcat-users.xml file (located at /Library/Tomcat/conf/tomcat-users.xml
),
and add a username and password combination for this role:
<tomcat-users> ... <role rolename="admin"/> <user username="hudsonadmin" password="hudsonadminpassword" roles="admin"/> ... </tomcat-users>
Save this file, and restart the server. Try accessing Hudson from another computer on the local network at http://localserveripnumber:8080/hudson
;
you should see the Hudson Dashboard: