Java JNDI Name java: /

I follow the tutorial: https://docs.oracle.com/javase/tutorial/jndi/index.html

My adventures began when I set the JNDI name for the data source from the WildFly application server. The name began with "java: /". I was curious what it was and how it worked.

I have a local Apache LDAP server and I can connect to it using

Hashtable<String, Object> env = new Hashtable<String, Object>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://localhost:10389/o=JNDITutorial");
    env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
    env.put(Context.SECURITY_CREDENTIALS, "secret");

    try {
        Context ctx = new InitialContext(env);
        Object obj = ctx.lookup("cn=Rosanna Lee,ou=People");
    } catch (NamingException e) {
        e.printStackTrace();
    }

My confusion is the JNDI name "java: /".

Can someone explain what “java: /” is and how can I use JNDI to interact with it?

My guess is its directory, located somewhere on my computer.

Thank.

+4
source share
1 answer

: JNDI - " Java". Java EE API java- . , .

, , JTA UserTransaction, java: comp/env. Java EE , beans, , JDBC DataSource . . , beans java: comp/env/ejb, JDBC DataSource java: comp/env/jdbc.

ref: http://docs.oracle.com/cd/E19798-01/821-1841/girdr/index.html

, Wildfly :

Java EE JNDI:

  • java: comp - (.. EJB)
  • java: module -
  • java: app -
  • java: global -

, WildFly :

  • Java: JBoss
  • Java:/

, "java:/" - ( ) Wildfly . " " , JDBC, EJB, LDAP ..

, Java EE :

+6

Source: https://habr.com/ru/post/1598113/


All Articles