You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by STEINER Stephan <St...@nextiraone.ch> on 2006/03/06 16:28:25 UTC

Using a configuration file without path for an application deployed on tomcat

Hi

I have developed a Java application which offers certain services to
Cisco IP phones. I've written it as a standalone java application to
separate processing logic and presentation. So basically I have a set of
classes, and two jsp frontend files that do very basic things. Since the
application can be run in standalone mode (for debugging purposes), I
have an xml configuration file which is assumed to be located in the
same directory as the application itself. Hence, my configuration reader
looks for a file config.xml without any path indication (since the path
can change). This works like a charm in the standalone configuration.
Then I added the jsp frontent using NetBeans. Netbeans has an integrated
Tomcat, and out of sheer luck I figured out that once my war is deployed
on the Netbeans Tomcat, my config.xml needs to be located not in the
path where the jar that contains the application logic (that one is put
in WEB-INF/lib where it belongs) but in the Tomcat bin directory. 

However, this no longer holds when I'm looking at a standalone Tomcat
installation. I've tried a bunch of different paths but with no luck. So
I'm wondering, if the app is looking for a config.xml without any path
indication whatsoever, where should I put it so that it will be find
once the jsp frontend starts the application? (and to go a little into
detail, the jsp is configuration oblivious and the application uses the
singleton pattern.. So in the jsp I'd write something like 
<% mypackage.Application myApp = new mypackage.GetApplication();
   myApp.DoSomething(); %>

And in mypackage.Application, I'd have

Static Application app = null;

Public static Application GetApplication()
{
	if (app == null)
	{
		app = new Application()
		app.loadConfig("config.xml");
	}
	return app;
}

So, where do I put config.xml so that loadConfig will find it? I presume
that if the NetBeans integrated tomcat mapps the local directory to the
bin directory, there should be something similar on a standalone tomcat
installation, should there not? And if this approach is doomed, then how
else can I get an xml configuration to the application without involving
the frontent jsp files?

Regards
Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org