Skip to Content
avatar image
Former Member

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

Hi,

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,

Ben

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="http://sdn.sap.com")
    URL myURL;
    

    This also declares an injection point.

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

    HTH!

    -- 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|http://help.sap.com/saphelp_nwce711/helpdata/en/72/ad92c5806d44899b9c3c187469d63f/frameset.htm] (Note: this comes with EHP1 for CE 7.1).

      HTH!

      -- Vladimir