aspose file tools*
The moose likes Tomcat and the fly likes Tomcat 7 - VirtualWebappLoader - is it a good option to use in production? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 7 - VirtualWebappLoader - is it a good option to use in production?" Watch "Tomcat 7 - VirtualWebappLoader - is it a good option to use in production?" New topic
Author

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

Ashish Parkhi
Greenhorn

Joined: Jul 10, 2012
Posts: 2
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?

Thanks,
Ashish
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16134
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ashish Parkhi
Greenhorn

Joined: Jul 10, 2012
Posts: 2
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.
 
subject: Tomcat 7 - VirtualWebappLoader - is it a good option to use in production?