Configuring GlassFish App Server with Apache httpd

Submitted by rizwan on Sat, 2007-10-20 16:37.

Here are the step by step instructions to configure GlassFish App server with apache web server.

Install & configure mod_jk:

Install apache web server and install the corresponding mod_jk. For instance if you have installed apache web server 2.2.4, go to the connectors web site of apache and download from the binaries mod_jk of the corresponding version of your installed web server. Then simply remove the version and place it in the modules directory according to your OS (I use windows OS and place it in C:/apacheroot/modules/ )

Create Workers File:

Create workers properties file inside the conf directory. If there is no sample then create it.Here is one sample you can put

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=hostname
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

Configure httpd.conf

This is the important step. Edit the httpd.conf from the conf directory.Here is one sample. Here I assume that I have defined the Apache web server root installation directory.


LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile log/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send all jsp requests to GlassFish
JkMount /*.jsp worker1

# Now add all your applications that want the request to be sent to glassfish
JkMount /yourapp/* worker1

Now start/re-start your webserver. If it fails it could be because of the path problems so go to the logs and identify the errors (apacheroot/logs/) and analyze all logs. If your web server starts bingo

You need to copy tomcat-ajp.jar,commons-logging.jar and commons-modeler.jar to the glassfish library. The tomcat-ajp.jar can be obtained from a tomcat source and the other two from the commons library.


Enable mod_jk in GlassFish:

Use the following command to enable mod_jk at glassfish server/
$GLASSFISH_HOME/bin/asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK=8009

Now re-start glassfish and try your apps through your webserver and there you go


Posted in Submitted by rizwan on Sat, 2007-10-20 16:37.

Comments

Vaibhavi (not verified) | Sat, 2009-01-24 09:57

Hi all, I am working for a software integrator company. My projects includes working on Java and Ruby on Rails and Ajax. I think Web Services is really cool. We also recently have to now work on REST and they are talking about mashups and Struts. Can anyone tell me if there are some good training or conferences so that me and my team members can get to speed with these technologies. Learning from books is not my cup of tea, even not when I was doing engineering ;) All the help that group members can provide in this regard is much appreciated. Thanks, Vaibhavi

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Main Links