Getting Experience Manager to work with HTTPD and Tomcat

In one of our current projects, we are using two-tiered web delivery approach:

  • Static files (images, js, css, etc) are served by Apache Httpd, a simple web server
  • Pages and dynamic component presentations are served by Tomcat

Our technology stack includes Web 8, DD4T 2, Spring MVC and Java 8.

Summing up the architecture in a picture, we get this:



Since the web application is set up to serve content from different publications (global site, country sites, etc), we rely on the publication mappings in the Topology Manager to resolve the publication ID for each request.  This is done by calling the following method in the CIL:

DynamicMappingsRetrieverImpl.getPublicationMapping(String url)

The way this works: the CIL makes a call to the discovery service, with the URL of the current request stored in an Ambient claim. The discovery service passes it on to the content service, which matches the URL with the publication mappings created in Topology Manager. See for an excellent explanation of how publication mappings work.

The ‘current URL’ passed to the service is the URL of the request to Tomcat, i.e. a request on port 8080. For example: http://mysite:8080/en-uk/index.html. Therefore, I mapped my publications to a URL on port 8080, as follows:

Set-TtmWebsite -Id WEBSITEID -BaseUrls "http://mysite:8080"

So far so good. But then I added Experience Manager to the mix (I’m not explaining how that’s done, maybe some other time). And I found I couldn’t get Update Preview to work. I kept seeing the following error:

Unable to preview the page. There is no publication target defined for this XPM enabled website. Contact your SDL Tridion administrator.

I dug around a bit, and found that the preview functionality also tries to find the publication ID for the current URL, using the same publication mappings. However, XPM uses the URL of the page as it is loaded in the editor, which in our case uses port 80: http://mysite/en-uk/index.html.

Changing the mapping from port 8080 to port 80 fixes the preview error, but breaks the page itself. The only solution is to map the publication to both URLs (port 80 and port 8080), like this:

Set-TtmWebsite -Id WEBSITEID -BaseUrls @("http://mysite",  "http://mysite:8080")

This solved our issue. Note that the way to enter multiple-value parameters in a Powershell cmdlet, is with the @(ARG1, ARG2, ARGN) syntax.