hmmm… (life, programming and everything)

Posts Tagged ‘virtual directory

Virtual directory in JBoss/Tomcat

without comments

[UPDATE]
The reason for the listing not showing JBoss 4.2.2 is due to the fact that ‘listing’ parameter in ‘jboss-web.deployer/conf/web.xml’ is ‘false’. Change it to ‘true’ so that the listing is shown.
[/UPDATE]

One of the projects that I am currently doing involves a huge bunch of htm, powerpoint and other image files that are independent of the application. The problem happens when you need to move the EAR from the test bed to the production machine. It takes a hell-lot of time to transport it. A nice alternative in such a case would be to configure virtual directories in your application server and put the index.html’s link in your app.

It’s a simple one line configuration in the tomcat’s server.xml file. In JBoss 4.0.4, this would be present under $JBOSS_HOME_DIR/server/default/deploy/jbossweb-tomcat55.sar.  The last folder will be jboss-web.deployer if it is JBoss 4.2.2 and above. Inside the tag “Host” add the following lines -

<Context path=”/virtual” docBase=”C:/physical_dir” />

This will let http://localhost/virtual to be mapped to the files under “C:\physical_dir”.

The funny thing is it doesn’t work as expected in JBoss 4.2.2 GA. I was struck for a long time to figure out how to make this work in JBoss 4.2.2. All the wiki’s and IRC channels I tried looking in had the same line shown above for JBoss 4.2.2 also. Strange! Frustrated, I tried the last option – “http://localhost/virtual/<filename>” and it worked “out of the blue”. I am not sure why this happenes in JBoss 4.2.2. Ideally it should show the files present in the directory that we are mapping it.

I will try updating this blog with the reason if I find it. Till then have fun!

Written by karthik3186

September 17, 2008 at 3:23 pm