• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Apache 2.5 with tomcat 8 setup problem

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an apache 2.4 on Debian Jessie and I host several sites as virtual hosts.
On of these sites is running on jsp so I hav installed tomcat 8 and I use mod_jk.

My virtual host configuration file for apache is:


On tomcat's server.xml I have a host record as:


Site is running here http://www.dimitros-apartments.gr and I get a "permission denied" error where I access http://www.dimitros-apartments.gr.

I use ispconfig and for each domain, I must have a directory where apache's domains directories resides, regardless if this domain is served from apache or in my case from tomcat. So for this domain I have a corresponding directory on both apache and tomcat. I also have an index.jsp on both tomcat domain root directory and apache's domain root directory.

When I access http://www.dimitros-apartments.gr/index.jsp I get an uncompiled jsp page ( I see the source code ) on my browser.
A strange think is that this uncompiled page, is not from tomcat's directory but from apache's domain directory.

any help is appreciated.

Thanks in advance,

Christoforos Korifidis
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this was resolved with the help of AndrĂ© Warnier  from tomcat mailing list.
For anyone having the same problem the solutin is to change


Saloon Keeper
Posts: 21133
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason for this is that "dimitros-apartments.gr" is the domain name. A URL in the Tomcat world consists of a domain part (domain name and optionally port number), a context part - which in this case identifieds which webapp within the target Tomcat server to send the request to, a servlet part, which tells Tomcat which servlet or JSP to send the request to, and a resource ID which can be used as an unnamed argument to the servlet or JSP.

Technically the servlet part is optional. If the URL, once domain and context parts are removed, matches a URL pattern defined for a servlet in the web.xml, then that's the servlet that gets the request. If it does not, there's an invisible "default servlet" that attempts to match the remaining URL path to a WAR-relative resource path of a JSP. And if neither of those attempts match, then the default servlet looks for a resource whose path matches the remaining URL and attempts to resolve it. If the resource is a directory, Tomcat generates a directory listing (unless told not to), if it's a regular "file" resource like CSS, javascript or an image, it generates suitable response headers to the response stream and copies the resource out as a response.

In your case, dimitros-apartments.gr domain name was defined to Apache as a VirtualHost, so that part is taken care of by Apache. Then the JkMount defines what the remaining parts of the URL are that will route to Tomcat. You can actually get very creative and make Apache-relative contexts that send requests to different backends. For example, ajp13_worker1 might receive all requests targeting dimitros-apartments.gr/tenants/ and send them to Tomcat Server1 and dimitros-apartments.gr/landlords/ might be JkMount'ed to be sent to Tomcat Server2. Or even to a non-Java backend server.

When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!