Skip to main content

context.xml - problem obtaining

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2009-04-18

I've put META-INF/context.xml in my WAR, with following content

<Environment    name="data-directory" value="/some/path" type="java.lang.String"/>

In tomcat I used
        Context initContext = new InitialContext();
        Context envContext = (Context) initContext.lookup("java:/comp/env");
        String dataDir = (String)envContext.lookup("data-directory");

to obtain "data-directory".
But how is this done in Glassfish?
I tried above code, and following:
            Context initContext = new InitialContext();
            tring dataDir = (String)initContext.lookup("data-directory");

but I always got a NamingException ("Lookup failed").
Any suggestions?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-04-18

There was an unnecessary "/" which causes the error. Using


and it works!