JSPWiki/Glassfish Install (Part 16 of 18: Integrate with Apache2)

Configure Glassfish

In order to have both a nice URL and grant access to the outside world (password protection will still be intact) we need to “hide” our glassfish installation and the JSPWiki application behind our existing web server. To pull off this trick we’ll need to add some additional “jars” to Glassfish.

The first couple of “jars” we’ll borrow from the Tomcat application we downloaded earlier. Find this zip file and decompress it.

  • Navigate to apache-tomcat-5.5.20\server\lib
  • COPY “tomcat-ajp.jar” and “commons-modeler.jar” to c:\java\glassfish-v2-b33e\lib

The second “jar” we’ll need is from the “commons-logging-1-1.zip” archive.

  • Decompress this archive
  • Find all the commons-logging*jar and COPY these files to c:\java\glassfish-v2-b33e\lib

In your command window cd to c:\java\glassfish-v2-b33e\bin then issue the command:

  • asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK=8009

OR, if you like the web interface to Glassfish, login and navigate to:

  • Application Server –> JVM Settings –> JVM Options
  • Once there click on Add JVM Options and enter “-Dcom.sun.enterprise.web.connector.enableJK=8009”

Restart Glassfish.

Configure Apache

We’ll use and configure two Apache modules:

  1. “rewrite” to clean up our incoming URL

  2. “jk” to coordinate/integrate/connect traffic to our Glassfish/JSPWiki application

The rewrite module is already probably already installed but you will probably have to install the jk module. On Ubuntu Linux (and Debian) as root you issue this command:

  • apt-get update; apt-get install libapache2-mod-jk

and the package magically installs! But we still have to do some configuration. Issue the following commands as root…

  • cd /etc/apache2/mods-enabled
  • ln -s /etc/apache2/mods-available/jk.load jk.load
  • ln -s /etc/apache2/mods-available/rewrite.load rewrite.load

While you’re still in /etc/apache2/mods-enabled create a new file “jk.conf”and enter these contents:

JkWorkersFile /etc/apache2/workers.properties
JkMountFile /etc/apache2/uriworkermap.properties
JkShmFile /var/log/apache/jk.shm
JkLogFile /var/log/apache2/jk.log
JkLogLevel debug
JkLogStampFormat “[%a %b %d %H:%M:%S %Y]”
JkRequestLogFormat “%w %V %T”
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

ServerName wiki.example.com
RewriteEngine on
RewriteRule ^/$ http://wiki.example.com/JSPWiki
ServerName http://www.wiki.example.com
RewriteEngine on
RewriteRule ^/$ http://wiki.example.com/JSPWiki

Don’t forget to adjust the domain names above to meet your needs. What this basically does is use the rewrite module to take the nice URL — wiki.example.com (entered by either the LAN users or Internet users) and change it to wiki.example.com/JSPWiki where the jk module will be waiting to feed this traffic back to Glassfish running on your LAN.

Pretty neat, huh!

  • cd /etc/apache2
  • create/edit a new file uriworkermap.properties and add:
  • /JSPWiki=wiki
  • /JSPWiki/*=wiki

create/edit a new file worker.properties and add:


# Define node1


# Define node2


# Load-balancing behaviour

#Status worker for managing load balancer


Restart Apache:

  • /etc/init.d/apache2 restart

Now, Apache should be “talking” to Glassfish.

To test this go to one of the PC’s on your LAN and put http://wiki.example.com or http://www.wiki.example.com into the web browser.

You should be presented with the login for you wiki! And, this will be the same behavior for you Internet users.

4 thoughts on “JSPWiki/Glassfish Install (Part 16 of 18: Integrate with Apache2)

  1. Hi, me again.Ok, I got the app working well on Glassfish, so I followed the steps on this page to ‘Configure Glassfish’.After I copied all of the jar files into my glassfish folder I tried to put in the create-jvm-options command into it but I fat-fingered the second part of the command. now whenever i try to start glassfish it runs saying that it cannot start the java virtual machine and that it does not recognize my command, and then doesnt start. I need it to be running to modify the jvm option but I cant get it to start. What can I do?


  2. Oh boy, I just don’t know the answer to that one. But you might be able to find an answer on either the glassfish mailing list or the netbeans mailing list. There are a bunch of developer types who utilize those lists and if you post your question there maybe one of the glassfish experts can give you a pointer.I follow those lists too but there are a lot of sun heavyweights on there who really know glassfish backwards and forwards; though I try to help where I can.Go to http://glassfish.dev.java.net and click on either Discussion Forums or Mailing Lists.


  3. OK, I got the JVM working, but now I am on the next step “configure Apache”. I am using windows, and when I put apt-get in my command line it tells me that it is a unrecognized command. Where do I type this command?Also, I dont have a ect/apache2/ folders anywhere. Do those get created from the prev command?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s