Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the physical path of my web app root context ?

yves77-OracleSep 1 2009 — edited Sep 3 2009
Hi,

I used this code to initialize my LOG4J logger.
        System.out.println(Version + "Servlet context path : " + sctx .getContextPath());
        String path = sctx .getRealPath("/");
        fullyqualifiedlog4jpath = path + "log4j.xml";
        File locallogxml = new File(fullyqualifiedlog4jpath);
        if (locallogxml.exists()) {
            initialized = true;
            DOMConfigurator.configure(fullyqualifiedlog4jpath);
            log = Logger.getLogger(Log4j.class.getName());
            log.info(Version + "Logger initialized");
        }
        else {
            System.out.println(Version + "Unable to locate the log4j.xml file");
        }
It works perfectly when running the application with the embedded Jdev11 WLS.

When deploying the application on a standalone WLS server the path is not returned ;-( I get a null value.

Does someone has three lines of code which get the physical path of my web app root context?

Yves
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2009
Added on Sep 1 2009
1 comment
646 views