Discussions

EJB programming & troubleshooting: Why use InitialContext()

  1. Why use InitialContext() (2 messages)

    If you construct an Initial Context using the no argument InitialContext() constructer, how does the initial context 'know' which naming service to connect to?

    Does it connect to the localhost?

    Threaded Messages (2)

  2. Why use InitialContext()[ Go to top ]

    This is determined by your application server container.

    In general, if you use the no-arg constructor, then yes, it will connect to the default JNDI service of the J2EE container running on the localhost.

    If you want to read it from another machine, you'll need to set up parameters first.
  3. Why use InitialContext()[ Go to top ]

    Hi!

    The actual class of your InitialContext is set as an environment parameter. See the Javadoc for javax.naming.InitialContext for all details.)

    Instantiating a subclass using the new InitialContext() looks very strange - at least to me. But it seems to be a built-in feature in the JVM, and you cannot copy this pattern if you want to write something similar.

    /Tomas