• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Context.PROVIDER_URL

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!All
What value should i pass to Context.PROVIDER_URL, when Setting up environment for creating the initial context?
I'm trying to bind and then lookup valid file object in JNDI using the following method and code.Im using j2sdk1.4.Im running my JNDI client as a standlone java class and not using ant App server. I have placed jndi.jar,fscontext.jar,providerutil.jar in <J2SDK_HOME>\jre\lib\ext folder

Here's the code
public static void main(String[] args)//throws FileNotFoundException
{
File file;
file=new File("C:\\work_dir\\helloworld.txt");
System.out .println("filename" +""+ file.getName());
System.out.println(file);
try
{
if(file.exists())//throw new FileNotFoundException();
System.out.println("file found");
else
System.out.println("file not present");
}
catch(Exception fe)
{
System.out.println(fe);
}
// Set up environment for creating the initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL," ");//what value to give??

try {
// Create the initial context
Context ctx = new InitialContext(env);

//bind the object
ctx.bind("myfile",file);
// Look up an object
File fileobj = (File)ctx.lookup("myfile");
System.out.println(fileobj);
//close the context
ctx.close();
}
catch (NamingException e)
{
System.err.println("Problem looking up " + ": " + e);
}
}

}


Thanx in advance for any kind of help.
Regards
ved
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ved,

I think I answered similar/same question by you on this forum (or was it the EJB Certification forum?...)...

Thanks
Maulin
 
ved gunjan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maulin Vasavada:
Hi Ved,

I think I answered similar/same question by you on this forum (or was it the EJB Certification forum?...)...

Thanks
Maulin



Originally posted by Maulin Vasavada:
Hi Ved,

I think I answered similar/same question by you on this forum (or was it the EJB Certification forum?...)...

Thanks
Maulin



Hi! Maulin
Ya Your are right.U answered my query in this forum only.U said that initial context parameter is App Server dependent.
What i want to say that i'm not using any App Server.Im running the JDNI code as standalone java application.I'm using File system service provider.
the code generates the following error
javax.naming.OperationNotSupportedException
Can u plz clarify what is going wrong and where.
Regards
Ved
canu tel
reply
    Bookmark Topic Watch Topic
  • New Topic