0 Replies Latest reply on Mar 1, 2004 8:43 AM by biondo79

    Set initial context

    biondo79 Newbie

      Hi! I´m a rookie on JBoss and I´would like to know the specific JNDI properties to set the InitialContext. I´m following the Titan Cruiser example. The JBoss EJB workbook doesn´t set anything, but at RunTime I got 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"

      Is there any Java .property file that I need to configure? Here is the class code:

      package com.titan.cabin;

      import javax.naming.InitialContext;
      import javax.naming.Context;
      import javax.naming.NamingException;
      import java.rmi.RemoteException;
      import javax.ejb.CreateException;
      import javax.ejb.FinderException;
      import java.util.Properties;
      import javax.rmi.PortableRemoteObject;

      public class Client_1 {
      public static void main(String[] args){
      Context jndiContext = getInitialContext();
      Object ref = jndiContext.lookup("CabinRemote");
      CabinHomeRemote home = (CabinHomeRemote) PortableRemoteObject.narrow(ref, CabinRemote.class);
      CabinRemote cabin_1 = home.create(new Integer(1));
      cabin_1.setName("Master Suite");

      Integer pk = new Integer(1);

      CabinRemote cabin_2 = home.findByPrimaryKey(pk);

      }catch(RemoteException re){re.printStackTrace();}
      catch(NamingException ne){ne.printStackTrace();}
      catch(CreateException ce){ce.printStackTrace();}
      catch(FinderException fe){fe.printStackTrace();}

      public static Context getInitialContext() throws NamingException{
      Properties p = new Properties();
      // Here is where my doubt is...
      return new InitialContext(p);