aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes NoInitialContextException: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "NoInitialContextException:" Watch "NoInitialContextException:" New topic
Author

NoInitialContextException:

Jatinder Singh
Greenhorn

Joined: Oct 31, 2006
Posts: 2
Hi,
i am trying to look up bean but getting exception as

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

for lookup i have written code as
jndiProp = new Properties();
jndiProp.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
jndiProp.put(Context.PROVIDER_URL, providerURL);

Context ctx = new InitialContext(jndiProp);
String ejbJndiName = ApplyLegacyProcessHome.JNDI_NAME;
Object obj = ctx.lookup(ejbJndiName);
but at ctx.lookup() i am getting exception.
Please help why this exception is coming
Thanks
Jatinder
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Gurbinder,
I'm only guessing, but don't you also need to define the following properties as well:
  • Context.SECURITY_PRINCIPAL
  • Context.SECURITY_CREDENTIALS

  • Good Luck,
    Avi.
    Jatinder Singh
    Greenhorn

    Joined: Oct 31, 2006
    Posts: 2
    Hi Avi,

    Thanks avi i got the solution just added naming.jar, namingclient.jar, namingserver.jar files in classpath. Now its working fine.

    cheers
    Tuhin Ghosh
    Ranch Hand

    Joined: Oct 11, 2006
    Posts: 33
    hi M also getting same problem,

    ERROR :>

    Caught an unexpected exception!
    javax.naming.NoInitialContextException: Need to specify class name in environmen
    t or system property, or as an applet parameter, or in an application resource f
    ile: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    40)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
    )
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:280)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at CurrconvClient.main(CurrconvClient.java:8)



    <CODE>

    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;

    public class CurrconvClient {
    public static void main(String[] args) {
    try {Context initial = new InitialContext();
    Object objref = initial.lookup("myconvert");

    CurrconvHome home = (CurrconvHome)PortableRemoteObject.narrow(objref,CurrconvHome.class);
    CurrconvRemote CurrencyConverter = home.create();
    double amount = CurrencyConverter.DollarstoRs(100.00);
    System.out.println(String.valueOf(amount));
    amount = CurrencyConverter.RstoDollars(100.00);
    System.out.println(String.valueOf(amount));
    }
    catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    }}}
    Suggest me wat to do?

    THANKS
    tuhin

    [ October 31, 2006: Message edited by: Tuhin Ghosh ]
    [ October 31, 2006: Message edited by: Tuhin Ghosh ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: NoInitialContextException:
     
    Similar Threads
    Websphere Naming Exception
    problem with WAS5.0 in getting connection from connection pool
    Cant get reference to Queue
    class cast exception
    regarding clas cast exception