• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Tomcat 7 - VirtualWebappLoader - is it a good option to use in production?

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently the SysOps team has to repackage the war file that we release with instance specific configuration. They are requesting us to externalize the configuration files (log4j.properties, environment.properties, jrf.properties, quartz.properties) out size the war file. That will make the deployment easier.

We are using Tomcat 7 and VirtualWebappLoader in Tomcat 7 looks like a very cool feature to externalize the configuration outside the war file. Tomcat 6 documentation explicitly states that "This is not meant to be used for production. Its meant to ease development with IDE's without the need for fully republishing jars in WEB-INF/lib"? Tomcat 7 documentation does not say so.

Any idea if VirtualWebappLoader feature can be used in production environment?

Posts: 20836
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Ashish!

I've been doing externally-injected configuration since long before Tomcat 7. Since Tomcat 5, at least. I have a strict policy that the exact same byte-for-byte-identical WAR gets deployed whether it's on the desktop, the Beta machine or full production. That allows me to be certain that any behaviors are not due to program logic differences as well as unfortunate incidents where the wrong WAR gets deployed so that for example, we don't discover that for the last week, the production webapp has been working off the test database.

Since the VirtualWebappLoader is new to Tomcat 7, obviously I've been doing it a different way. Just for the record, however, I don't think that the VirtualWebappLoader is really appropriate for this sort of use.

What I do instead is define the variable constituents (config file locations, run option settings and so forth) as Context properties. The webapp then retrieves them using JNDI.

Ashish Parkhi
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim!

So I guess I could configure the locations using either of the options below

<Parameter name="jrf" value="c:/jrf.properties" override="false"/>
<Environment name="environment" value="c:/environment.properties" type="java.lang.String" override="false"/>

and either use servletcontext (getInitParameter) OR Context envCtx = (Context) initCtx.lookup("java:comp/env"); to load those values..

If I do that, I will have to modify all the existing code where ever we are using ResourceBundle to load the resources from the class path. And there is a third party software jrf, which loads jrf.properties using ResourceBundle. And I cannot modify this code.

That is why I was hoping to use an option like below to load the configuration files from additional external class path C:/externalresources/

<Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="C:/externalresources/" />

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!