Try this...


String configFileName = "/com/common/logger.xml";

Always use forward slashes when dealing with class loader paths. These are Java packages, not system directories (even though they look similar).

One other thing. Where is the class you are using to load the logger.xml file? Is it in the same package as logger.xml (actually, I just noticed it is the InitialContext class, so the answer is no, it isn't in the same package, but anyway...)? If so, then just do..

String configFileName = "logger.xml";

When using the getResource() method from the Class class, resources are relative to the class. Notice in the first example that I overrode this the relative path by including a preceding forward slash which makes it look for the resource starting from the root package. You can also use the ClassLoader.getResource() method and remove the preceding forward slash to do the same thing.

Jake

At 07:23 PM 9/7/2003 -0700, you wrote:
Hi,

I am trying to configure log4j for an app. Currently, I have deployed
it on Tomcat. My code snippet is -

..............
String configFileName = "com.common.logger.xml";
URL url = null;
Context ctx=null;
ctx = new InitialContext();
url = ctx.getClass().getResource(configFileName);
.....................

I put the xml file under a directory structure under classes in my
web-app. The issue is that the URL is null.

I also tried other options like making the string
\com\common\logger.xml and com\common\logger.xml

Another approach I tried was to get Thread.currentThread.getClassLoader
and read the URL from there, I get a vague null pointer exception and
zip exception.

I am sorry if this is a very elementary question, but I could not find
any solutions in the lists also.

Krishna.



---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to