现在的位置: 首页 > 综合 > 正文

部署hudson时报错解决方案

2018年05月07日 ⁄ 综合 ⁄ 共 3104字 ⁄ 字号 评论关闭

启动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. Once it is uploaded, it is unpacked
in the “webapps/hudson” directory. Ultimately this will be the only application that I’ll be running under Tomcat, so eventually I’ll be replacing ROOT with Hudson, but for now we’ll take the defaults.

STEP 2: Configuring the Java environment variables

After attempting to launch Hudson using the url http://localhost:8080/hudson and
getting error messages, I checked the log files to see what error messages may be there. One of the error messages was:

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:

抱歉!评论已关闭.