Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Frits Walraven
  • Himai Minh

How to map Global JNDI name and ENC.

Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Glassfish, I have created a global JNDI name :

JNDI name = jdbc/abcd .

And in my code, I tried to inject the resource with the same name:

private static DataSource ds;

I assume that this will be interpreted as Environment Naming Context (ENC) name : java:comp/env/jdbc/abcd .

Fortunately I think Glassfish will automatically resolve ENC name to global JNDI name if a resource with the same Global JNDI name exists.

But what if I have :

@Resource (name="Some_Portable_JNDI_Name")
DataSource ds;

And still my global JNDI name on server is jdbc/abcd.

How to provide the mapping between ENC (java:comp/env/Some_Portable_JNDI_Name) and Global JNDI name (jdbc/abcd) in this case?

I think I have to provide this mapping in Glassfish specific deployment descriptor?
May I know waht is that and how to provide mapping?

I dont want to rely on mappedName property of @Resource annotation as that makes code difficult to port.
Hug your destiny! And hug this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic