- This topic has 1 reply, 1 voice, and was last updated 20 years, 9 months ago by
Prash.
-
AuthorPosts
-
PrashMemberAm trying to run the following client :
(one of the examples in EJB workbook by O’Reilly)
———————————————————
package com.titan.clients;
import com.titan.cabin.CabinHomeRemote;
import com.titan.cabin.CabinRemote;import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;public class Client_1
{
public static void main(String [] args)
{
try
{
Context jndiContext = getInitialContext();
Object ref = jndiContext.lookup(“CabinHomeRemote”);
CabinHomeRemote home = (CabinHomeRemote)
PortableRemoteObject.narrow(ref,CabinHomeRemote.class);
CabinRemote cabin_1 = home.create(new Integer(1));
cabin_1.setName(“Master Suite”);
cabin_1.setDeckLevel(1);
cabin_1.setShipId(1);
cabin_1.setBedCount(3);Integer pk = new Integer(1);
CabinRemote cabin_2 = home.findByPrimaryKey(pk);
System.out.println(cabin_2.getName());
System.out.println(cabin_2.getDeckLevel());
System.out.println(cabin_2.getShipId());
System.out.println(cabin_2.getBedCount());}
catch (java.rmi.RemoteException re){re.printStackTrace();}
catch (javax.naming.NamingException ne){ne.printStackTrace();}
catch (javax.ejb.CreateException ce){ce.printStackTrace();}
catch (javax.ejb.FinderException fe){fe.printStackTrace();}
}public static Context getInitialContext()
throws javax.naming.NamingException
{
return new InitialContext();
/**** context initialized by jndi.properties file
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, “org.jnp.interfaces.NamingContextFactory”);
p.put(Context.URL_PKG_PREFIXES, “jboss.naming:org.jnp.interfaces”);
p.put(Context.PROVIDER_URL, “localhost:1099”);
return new javax.naming.InitialContext(p);
*/}
}————————————-
The following exception is thrown :
——————————————–
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(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.titan.clients.Client_1.main(Client_1.java:19)
———————————————————————–The called EJB is already deployed, shows up in the JMX-console.
Now, I kno dat jndi.props file shud b present in the class path , but how do I create one? wot r the contents of the file? Wot parameters to use?
help!
September 8, 2004 at 5:13 am #214754
PrashMemberproblem solved, sorry
-
AuthorPosts