• Post Reply Bookmark Topic Watch Topic
  • New Topic

Context.PROVIDER_URL  RSS feed

 
ved gunjan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!