standalone client with websphere 4.0


EJB programming & troubleshooting: standalone client with websphere 4.0

  1. standalone client with websphere 4.0 (1 messages)

    I've created a Rental.ear, with the mehtods given at This contains RentalSesseion.jar and Rental.war. I've successfully tested the application using web client i.e. by typing http://localhost:9080/rental/RentACar

    I want to test the deployment using a standalone thin client (not sure whether the jargon is correct or not). This is my client program:

    package rental.client;

    import rental.ejb.session.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import java.util.Properties;

    public class
    CarClient {

    public static void main (String args []) throws Exception {

    Properties props = new Properties();

    props.put(Context.INITIAL_CONTEXT_FACTORY, "");
    props.put(Context.PROVIDER_URL, "iiop://localhost:900");

    Context ctx = new InitialContext(props);

    Object obj =

    RentalClerkHome home = (RentalClerkHome) javax.rmi.PortableRemoteObject.narrow (obj,RentalClerkHome.class);

    RentalClerk rclrk = home.create ();

    rclrk.rentVehicle ("1");

    I am getting following error while running the cient:

    javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
    at javax.naming.spi.NamingManager.getURLObject(
    at javax.naming.spi.NamingManager.getURLContext(
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(
    at javax.naming.InitialContext.lookup(
    at rental.client.CarClient.main(
    Exception in thread "P=574692:O=0:CT"
  2. This is because JNDI names starting with 'java:' are actually URLs. To be able to access objects in JNDI through URLs you must first set corresponding JNDI URL context factories. They are usually set up by J2EE environment (client or server) for you.

    The simplest and the most right way is to use <WAS_Home>\bin\launchClient.bat utility to launch you client (I don't know if it has the same name in new versions of WAS). The utility initializes J2EE client environment and, as part of the process, sets up URL context factories for JNDI so that you can now use JNDI names starting with 'java:'.

    But before you launch the client make sure you defined mappings of JNDI references (names starting with java:) used in your client to actual JNDI names as you usually do for the server side components.

    You can also remove code that sets JNDI properties. Context.INITIAL_CONTEXT_FACTORY property is automatically set up by the client environment and you can specify provider URL as command line argument of the launchClient.bat.