03 May 2006

OC4J Virtual Directory Mapping

The OC4J web module supports setting a virtual directory. The virtual directory allows a web module to serve content from a physical directory outside of the actual deployed web module.

In the orion-web.xml file the tag is of this form:

<virtual-directory virtual-path="/bar" real-path="D:\static_content\bar" />

Which means that when the web module is deployed it can serve content directly from the self contained WAR file (and its sub-directories) via the URL of /foo.

But it also means that the web module can now also serve content from the directory specified as the real-path attribute via the URL of /foo/bar.

You can specify this virtual-directory setting using an embedded orion-web.xml in which it is already set OR with the OC4J 10.1.3 release you can use the funky Deployment Plan Editor to specify it at deployment time.

This can be handy for example when you have web modules which need to serve content which is being periodically generated by other services such as a report engine (or graphic designers updating HTML or images) but don't want to lump the content into the exploded directory of the web module.


Anonymous said...

after I made the change and restart jdev embedded oc4j, the xml is reloaded and all changes were discarded. How this happen?


buttso said...

JDeveloper has some idiosynchrasies in that it seems to have ownership over certain sets of files. I recall seeing recently a post on the OTN J2EE/OC4J forum where someone was seeing JDeveloper continually override the web app class-loader settings specified in the orion-web.xml file.

I can't comment sensibly on what JDeveloper does. I know this option is available when you deploy to OC4J standalone and run there.

Cutto said...


First of all, sorry about my English: it's not as good as I'd like, and thanks for sharing your knowledge.

Mapping a virtual dir like you explain here could be a solution to a problem I'm facing with an app.

However, I was thinking about another way, and I don't knwo if it could be done. Maybe you know the answer.

Is there any way of configuring the "embebed" Apache server that comes with IAS, to serve the static content (images in my case) from the same path the app is using, using a directory located within the Apache docroot?

served by IAS (context root /myapp) but
served by Apache (from htdocs/myapp)

Hope it's kind of clear

Thanks in advance