Loading
NameNotFoundException

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  javax.naming.NameNotFoundException


Ans)

You get this Exception during the JNDI look up, if the Bean or the Resource is not available with the
given JNDI name , this will be thrown.
 

In order to fix do the following.
 

i) Firstly review the way you do JNDI look up is incline with your App Server Specification.
 

J2ee Server (sun) :
Context subcontext = (Context) ic.lookup("java:comp/env");
DataSource dataSource = (DataSource)
subcontext.lookup("jdbc/default-datasource");

Weblogic :
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
try {
ctx = new InitialContext(ht);
ctx.bind("my_object", MyObect);
ServiceBean bean = (ServiceBean)ctx.lookup("ejb.serviceBean");
}
catch (NamingException e) {
// a failure occurred
}

WebSphere:
Properties p = new Properties();
p.put("org.omg.CORBA.ORBClass","com.sun.CORBA.iiop.ORB");
p.setProperty( javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory" );
p.setProperty( "java.naming.provider.url", "iiop://HOSTNAME:PORT" );

String connectionfactoryjndi="jms/testQCF";
Context jndiContext = new InitialContext();
jndiContext = new InitialContext( p );

 

ii) Secondly please restart your Application Server like Welogic or WebSphere beacuse unless
you restart some of the App Services will not BIND the resource .
 

iii) Then  take a look at JNDI tree in App Server if it has one built in if not print the resource names as shown below and search for your Resource.
 

Print JNDI Tree :
Context ic = new InitialContext(properties);
context.list(ct);


Browse JNDI Tree:
http://servername:port_number/jndiTree/index.html



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

NameNotFoundException


NameNotFoundException

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free