I have downloaded sun's j2ee1.4 sdk from their site and installed on my computer and applied all necessary tasks to call an ejb and succeeded. But what I found was, the EJBs were only accessible if the client was deployed on j2ee server that sun provided. The clients that I developed by JDeveloper 9i gets an error saying name not found. Although I succesfully get java:comp/env I could not reach my EJB. After some searches on this site I found many different ways of connecting to a name server(many BEA examples).
Now what I wonder is
1. Do I have to write different code for every application server to connect the ejb that is installed on them ?
2. If there are two or more name servers or application servers with different ports and IPs how can I indicate which one to connect by code
thanx for your patience if you read this far
There are two ways to get an InitialContext instance: you can create it without any parameters (new InitialContext()) and get a JNDI connection to whatever the JDK defaults. You can change the defaults on the client's command line by specifying:
If you have to connect to more than one JNDI, you have to use the second approach; you can pass the JNDI connection properties to the constructor in a hash table:
Hashtable props = new Hashtable();
Context ctx1 = new InitialContext(props);
Context ctx2 = new InitialContext(props);
Basically the factory and host name will differ based on the APPSERver u r using..Better get these values from properties file.So u no need to change the code according to the server..just changing the properties file will be enough.