Skip to Content
avatar image
Former Member

JNDI: How to configure an URL ressouce under java:comp/env/...?


I'm looking for a possibility to configure an URL resource in the CE 7.1 Java WAS.

The application needs to lookup an URL resource. The URL resource should be provided

by the application server under the JNDI tree, let's say: "java:comp/env/myURL"

Question: Is this possible with the CE 7.1 Java WAS to register a simple URL resource

in the JNDI tree? If yes, how? Or is it possible to register a custom resource type,

providing an factory class and so on?

It is possible with other JEE application server, such as BEA WebLogic,

Sun Application Server, now known as Glassfish, JBoss or even with an

ordinary servlet container, such as Tomcat.

thanks in advance,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 31, 2009 at 04:21 AM

    Hi Ben,

    This is a standard Java EE feature, and as such is supported by all compliant Java EE servers - so this means NW AS Java too.

    You can have this entry created for your EJB or web component by declaring a reference - either via annotations or in the DD. For example:

    @Resource(name="myURL", mappedName="")
    URL myURL;

    This also declares an injection point.

    Note that usage of mappedName is not portable, however it's supported by most app servers.


    -- Vladimir

    Add comment
    10|10000 characters needed characters exceeded

    • Well, this portability issue is different from what I meant above. For sure, declarations of resource refs, and environment entries in general, are portable and supported by all Java EE compliant servers. (It's the linking of the reference to the actual resource that's not portable in certain cases.)

      That said, you could certainly go for the simple string env entry and create the URL object yourself after having looked up its value. You create the env entry either in the ejb-jar.xml or via the @Resource annotation. What's even better is that if you're using EJBs you can change (customize) the value at runtime, without the need for redeployment of your app.

      For more information: [Editing EJB Environment|] (Note: this comes with EHP1 for CE 7.1).


      -- Vladimir