ejb client access code

Discussions

EJB programming & troubleshooting: ejb client access code

  1. ejb client access code (3 messages)

    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

    Threaded Messages (3)

  2. ejb client access code[ Go to top ]

    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:
    -Djava.naming.provider.url=iiop://jndi-host:9010, and
    -Djava.naming.initial.factory=com.sun.jndi.cosnaming.CNCtxFactory

    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();
    props.put(Context.PROVIDER_URL, "iiop://jndi-host:9010");
    props.put(Context.INITIAL_CONTEXT_FACTORY,
          "com.sun.jndi.cosnaming.CNCtxFactory");

    Context ctx1 = new InitialContext(props);
    ...
    props.clear();
    props.put(Context.PROVIDER_URL, "iiop://jndi-host-2:10920");
    props.put(Context.INITIAL_CONTEXT_FACTORY,
          "com.oracle.jndi.blah.Blah");
    props.put(Context.SECURITY_PRINCIPAL,"scott");
    props.put(Context.SECURITY_CREDENTIALS,"tiger");

    Context ctx2 = new InitialContext(props);

  3. ejb client access code[ Go to top ]

    Ferhat thanx
    (Teşekk├╝rler :)))
  4. ejb client access code[ Go to top ]

    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.

    Inian