Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Full disclosure: Since this seems to be more of a configuration issue, I deleted this from Stack (where it wasn't getting any response) and reposted here.

The problem is how to change the requestContextPath served up by Glassfish behind mod_proxy_ajp. The site/app runs fine if connecting directly to Glassfish port 8080 which is ultimately not what I want to do.

So I need help with configuration for my servers and jsf deployment. I can see the issue but don't know how to resolve it. It has to do with the requestContextPath.

  • Simply put, Apache directs to which is correct and what I want, but the page is minus the images and styles.

  • The issue is Glassfish itself is still pointing to*. So all links it serves in the app/site still refer via the requestContextPath. That is the /myapp/* part of

  • When I look in the page source, images which are referred to with relative links still point to the requestContextPath (that is, /myapp/). This is fixable but a real pain.

However with page links I can't set the relative path.

  • If I hover over the contact page link I see, and if I click it, I get 404. You can see the /myapp/ context path in the page source as well.

  • If I type in the URL I get the page minus its referred links (requestContextPath).

On Apache

ProxyPass / ajp://littlewalterserver:8009/myapp-web/

ProxyPassReverse / ajp://littlewalterserver:8009/myapp_Project-web

On Glassfish

asadmin create-network-listener --listenerport 8009 --protocol http-listener-1 --jkenabled true jk-connector

I have tried going in to Glassfish and setting the web app as the default web app. I have changed the / in glassfish-web.xml (and checked to make sure it was the same in the EAR file).

How can I get Glassfish to not include the /myapp/ context in the URLs? This has to be easy if you know how, but I don't know how, can someone help out here? Thanks.

share|improve this question
You don't have to delete questions to migrate them manually to another sx: Just flag them to the moderators for migration. – Martin Schröder Sep 21 '12 at 9:04

I found something that works right now.

As a preliminary, I think that when I set the default web app in the security tab I had also set <context-root>/</context-root> in the glassfish-web.xml at the same time. For sure this didn't work.

What worked is that I set the web app of the EAR to be the default web app in the glassfish console security screen and removed the <context-root>/</context-root> from glassfish-web.xml.

Then I changed the proxypass lines in httpd.conf to:

ProxyPass / ajp://myapp-web/

ProxyPassReverse / ajp://myapp_Project-web

It works but it kind of defeats one of the purposes of using proxy which is to allow the web app to keep running in its context but give the user something easy to link to. You can only have one default web app in a context so that limits you severely if you want to add more sites a la content management with Glassfish. Without a log of rewriting that is. Too bad they couldn't figure something out to make it 'just work'.

I can still use apache to serve static content and to act as the front door for SSL connections, but not too pleased with this approach. If someone knows a better way I'm still up for it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.