2 Replies Latest reply on Mar 15, 2006 10:14 AM by kryptontri

    please help me in this issue

    sobhi80

      Caught an exception.
      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
      at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at samples.ejb.bmp.simple.client.StorageBinClient.main(StorageBinClient.java:20)


      how can i solve it here is the code:

      Context initial = new InitialContext();
      Object objref = initial.lookup("java:comp/env/ejb/SimpleStorageBin");

      StorageBinHome storageBinHome =
      (StorageBinHome)PortableRemoteObject.narrow(objref,
      StorageBinHome.class);

      objref = initial.lookup("java:comp/env/ejb/SimpleWidget");

      WidgetHome widgetHome =
      (WidgetHome)PortableRemoteObject.narrow(objref,
      WidgetHome.class);

      String widgetId = "777";
      StorageBin storageBin = storageBinHome.findByWidgetId(widgetId);
      String storageBinId = (String)storageBin.getPrimaryKey();
      int quantity = storageBin.getQuantity();

      Widget widget = widgetHome.findByPrimaryKey(widgetId);
      double price = widget.getPrice();
      String description = widget.getDescription();

      System.out.println(widgetId + " " +
      storageBinId + " " +
      quantity + " " +
      price + " " +
      description);

      System.exit(0);

        • 1. Re: please help me in this issue
          kryptontri

          Sounds like you are running this from a separate jvm, ie not inside jboss. If this is so, you need to construct your initial context with environment vaiables like PROVIDER_URL etc, you are doing new InitialContext(), inside the jboss server instance this would work. So

          HashMap map = new HashMap();
          map.put(Context.PROVIDER_URL, "your url");
          .. more values like principal etc
          
          Context ctx = new InitalContext(map);
          ..
          


          try that ..

          • 2. Re: please help me in this issue
            kryptontri

            or you could put a jndi.properties file with these values in your path, that should work