As promised here is my Glassfish and Mercurial how-to:
I started out by creating a new project in NetBeans and selected "Web Application" from the "Web" category as project template, and called the project "cgi-bin".
Then I opened the web.xml file, and edited it so
it looks like below:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
The class org.apache.catalina.servlets.CGIServlet does not have to be created,
as it is bundled with Glassfish.
Now I created the WEB-INF/cgi directory and copied the hgweb.cgi
file from the Mercurial distribution to that directory,
and changed the location of the repository and the name of the repository to reflect upon our configuration:
#!/usr/bin/env python
#
# An example CGI script to use hgweb, edit as necessary
import cgitb, os, sys
cgitb.enable()
# sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.request import wsgiapplication
import mercurial.hgweb.wsgicgi as wsgicgi
def make_web_app():
return hgweb("/java/hg/jdk7", "JDK 7 repository")
wsgicgi.launch(wsgiapplication(make_web_app))
After that I built the project and deployed the cgi-bin.war file,
and can now access my JDK 7 repository at http://server/cgi-bin/hgweb.cgi.
security-constraint
section in my web.xml file:
<security-constraint>
<display-name>Mercurial</display-name>
<web-resource-collection>
<web-resource-name>Mercurial</web-resource-name>
<description/>
<url-pattern>/cgi-bin/hgweb.cgi</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>mercurial</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>Role for accessing hgweb.cgi</description>
<role-name>mercurial</role-name>
</security-role>
And configure my authentication domain and people will have to authenticate before they can access the repository.






Posted by Darren Moffat on September 20, 2006 at 04:02 AM PDT #
Posted by Stephen on September 21, 2006 at 10:58 AM PDT #