What is the initial context factory for sun's EJB reference implementation, and how is the initial context url specified? I always see the code fragment "InitialContext ctx = new InitialContext();" but where are the initial properties specified for this to work?


When you are getting an initial context from outside of the EJB Container, you must specify the properties for the initial context. These properties include the InitialContextFactory class, the url of the server, and possibly authentication parameters. These properties can either by created programatically using a java.util.Properties object, or can be loaded at runtime from the jndi.properties file in the classpath.

If you are using Sun's J2EE reference implementation in developing and deploying EJBs, you are most likely including the J2EE.jar file in your classpath, which is located in %J2EE_HOME%lib. If you look inside of this jar file, you will notice that in the root of the jar file there is a jndi.properties file. This file sets up the initial context properties for the Sun J2EE reference implementation. This is why you can just make a call such as:

Context ctx = new InitialContext();

without setting up the initial context properties, when using the Sun reference platform. If you use any other J2EE Application server, you will be required to set up those properties.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact