Thank you for clear explanation, I have one question, let say I have a web-app called myApp, and it contains a context.xml. And during deployment the name of the context.xml is automatically changed to myApp.xml. Then how does the context lookup happens, given we are doing it with Context envContext = (Context)initContext.lookup("java:comp/env"); How java:comp/env does all the magic?
I have created a topic in jms module in weblogic but while searching with it's jndi name I'm not able to lookup the topic. How to lookup that topic? Thank you..
Sir I am using your tutorial to learn jndi. I have set up my code exactly as your own. But when I run it gives a null pointer exception. I am pasting the code below for your review. Please help; Thanks. import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.*; public class Ctxclass{ public static void main(String[] args) throws NamingException { Hashtable env= new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL,"file:/C:/"); Context ctx = new InitialContext(env);
Driver xyz = new Driver("princeton", "rav4"); ctx.bind("best driver", xyz);}}
@Override public Reference getReference() throws NamingException {
Reference bill = new Reference(Driver.class.getName()); bill.add(new StringRefAddr(name, this.name)); bill.add(new StringRefAddr(model, this.model)); return bill;}} Exception in thread "main" java.lang.NullPointerException at java.util.Hashtable.put(Unknown Source) at com.sun.jndi.fscontext.RefFSContext.addObjectToBindings(RefFSContext.java:517) at com.sun.jndi.fscontext.RefFSContext.bindObject(RefFSContext.java:337) at com.sun.jndi.fscontext.RefFSContext.bind(RefFSContext.java:169) at com.sun.jndi.fscontext.FSContext.bind(FSContext.java:167) at javax.naming.InitialContext.bind(Unknown Source) at Ctxclass.main(Ctxclass.java:22)
3:30 code demo
4:06 (naming) *service provider* configuration
5:28 in this example case,
5:38 specify: use file system as service provider
Thank you Sir. Good simple practical explanation. Even a novice like me can understand. Thank you.
Best explanation of the concept. +1
thank you very much! very helpful and well explained!
Thank you for clear explanation, I have one question, let say I have a web-app called myApp, and it contains a context.xml. And during deployment the name of the context.xml is automatically changed to myApp.xml. Then how does the context lookup happens, given we are doing it with
Context envContext = (Context)initContext.lookup("java:comp/env");
How java:comp/env does all the magic?
I have created a topic in jms module in weblogic but while searching with it's jndi name I'm not able to lookup the topic. How to lookup that topic? Thank you..
Thank you!!!
Well done!
Sir I am using your tutorial to learn jndi. I have set up my code exactly as your own. But when I run it gives a null pointer exception. I am pasting the code below for your review. Please help; Thanks.
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.*;
public class Ctxclass{
public static void main(String[] args) throws NamingException {
Hashtable env= new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL,"file:/C:/");
Context ctx = new InitialContext(env);
Driver xyz = new Driver("princeton", "rav4");
ctx.bind("best driver", xyz);}}
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
public class Driver implements Referenceable {
String name;
String model;
Driver(String name, String model) throws NamingException{
this.name = name; this.model = this.model;}
@Override
public Reference getReference() throws NamingException {
Reference bill = new Reference(Driver.class.getName());
bill.add(new StringRefAddr(name, this.name));
bill.add(new StringRefAddr(model, this.model));
return bill;}}
Exception in thread "main" java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at com.sun.jndi.fscontext.RefFSContext.addObjectToBindings(RefFSContext.java:517)
at com.sun.jndi.fscontext.RefFSContext.bindObject(RefFSContext.java:337)
at com.sun.jndi.fscontext.RefFSContext.bind(RefFSContext.java:169)
at com.sun.jndi.fscontext.FSContext.bind(FSContext.java:167)
at javax.naming.InitialContext.bind(Unknown Source)
at Ctxclass.main(Ctxclass.java:22)
Takuntor Fred I'd try working with D:\ partition. Windows can be very tricky and restrictive about creating files at root of C partition.
jEdu Thank you so very much sir. Thank you for responding. I tried your suggestion and it worked perfectly.Thanks. I'm really grateful.
4:08 We may access the Naming Service with anus service provider??? What are you saying??? Fix your audio or add subs PLEASE!
Oof if you're here now.