• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

NameNotFoundException

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I got NameNotFoundException for my following client main method program.

package client;
/*
* HelloClient.java
*
* Created on January 27, 2007, 8:37 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import hello.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import javax.ejb.*;
import java.util.*;
/**
*
* @author Administrator
*/
public class HelloClient {

/** Creates a new instance of HelloClient */
public HelloClient() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
p.put(Context.PROVIDER_URL,"file://localhost:3700"); //1099
Context context = new InitialContext(p);
Context ctx=(Context)context.lookup("java:/comp/env");
Object o=ctx.lookup("HelloLocalHome");
System.out.println("home object has been brought");
HelloLocalHome home=(HelloLocalHome)o;
HelloLocal advice=home.create();
System.out.println(advice.sayHello());
}
catch(Exception ex)
{
ex.printStackTrace();
}
}

}


but I got the error as follows.I need to get the answer.help me to solve it.

init:

deps-jar:

compile-single:

run-main:

javax.naming.NameNotFoundException; remaining name 'E:\localhost:3700'

at com.sun.jndi.fscontext.FSContext.checkExists(FSContext.java:850)

at com.sun.jndi.fscontext.FSContext.checkIsDirectory(FSContext.java:883)

at com.sun.jndi.fscontext.FSContext.<init>(FSContext.java:108)

at com.sun.jndi.fscontext.FSContext.<init>(FSContext.java:81)

at com.sun.jndi.fscontext.RefFSContext.<init>(RefFSContext.java:97)

at com.sun.jndi.fscontext.RefFSContextFactory.createContext(RefFSContextFactory.java:42)

at com.sun.jndi.fscontext.RefFSContextFactory.createContextAux(RefFSContextFactory.java:47)

at com.sun.jndi.fscontext.FSContextFactory.getInitialContext(FSContextFactory.java:49)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.init(InitialContext.java:219)

at javax.naming.InitialContext.<init>(InitialContext.java:195)

at client.HelloClient.main(HelloClient.java:36)

BUILD SUCCESSFUL (total time: 0 seconds)
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the lookup failed, and could be ebcause a few reasons. All related to



1. the Provider_url looks weird to me, it is not normally a "file" and it is usually port 1099 for Naming services.
2. There is one more property that is missing, just don't remember the exact name.

Context ctx=(Context)context.lookup("java:/comp/env");
Object o=ctx.lookup("HelloLocalHome");

Not sure why you "lookup" a context, when you already have the InitialContext and you can lookup your bean from that, so that you only have one network call there, rather than two. You lookup of your bean could be the wrong name.

Mark
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic