ejb client access code


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

    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");

    Context ctx1 = new InitialContext(props);
    props.put(Context.PROVIDER_URL, "iiop://jndi-host-2:10920");

    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.