02. JNDI - start of work with Context interface (1)

Поділитися
Вставка
  • Опубліковано 1 лют 2025

КОМЕНТАРІ • 13

  • @ruixue6955
    @ruixue6955 8 місяців тому

    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

  • @takuntorfred2212
    @takuntorfred2212 9 років тому

    Thank you Sir. Good simple practical explanation. Even a novice like me can understand. Thank you.

  • @thecritique5464
    @thecritique5464 10 років тому

    Best explanation of the concept. +1

  • @galmalachi4859
    @galmalachi4859 9 років тому

    thank you very much! very helpful and well explained!

  • @ashishburnwal9010
    @ashishburnwal9010 5 років тому

    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?

  • @PriyankaShinde-mp6lt
    @PriyankaShinde-mp6lt 5 років тому

    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..

  • @svalyavasvalyava9867
    @svalyavasvalyava9867 3 роки тому

    Thank you!!!

  • @WojtekHejna
    @WojtekHejna 10 років тому

    Well done!

  • @takuntorfred2212
    @takuntorfred2212 9 років тому

    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)

    • @jedu1352
      @jedu1352  9 років тому +1

      Takuntor Fred I'd try working with D:\ partition. Windows can be very tricky and restrictive about creating files at root of C partition.

    • @takuntorfred2212
      @takuntorfred2212 9 років тому

      jEdu Thank you so very much sir. Thank you for responding. I tried your suggestion and it worked perfectly.Thanks. I'm really grateful.

  • @aaroldaaroldson708
    @aaroldaaroldson708 6 років тому

    4:08 We may access the Naming Service with anus service provider??? What are you saying??? Fix your audio or add subs PLEASE!

  • @rallokkcaz
    @rallokkcaz 3 роки тому +1

    Oof if you're here now.