This discussion is archived
2 Replies Latest reply: Oct 12, 2007 1:12 AM by 807600 RSS

Connetct to JNDI

807600 Newbie
Currently Being Moderated
Hi everybody!

I would be pleased if smb could help me...

I have a problem with connecting to my bean from a client side. Here is the client code example.
         Context ctx = new InitialContext();
         converter = (Converter) ctx.lookup("MyBean\remote ");
         ConverterClient client = new ConverterClient();
I got "occuredjavax.naming.NoInitialContextException:". That means there is nothing in ctx after executing that code.
I see that my bean is in the JNDI global namespace, so everything is ok with it.

I guess that I have to define properties, but I didn't find an appropriate variant for my case. Actually, I'm confused what should I put in "env.put".
 
         Properties env = new Properties();     
         env.put("java.naming.factory.initial", "??????");
         env.put("java.naming.provider.url", "??????");
  • 1. Re: Connetct to JNDI
    EJP Guru
    Currently Being Moderated
    Your problem starts with the title. You don't 'connect to' JNDI, you use JNDI to 'connect to' naming services. There is no such thing as a JNDI server.

    So, first question, what naming service are you trying to connect to?

    The answer to that determines what goes in the env.put() calls. Then you need to pass that environment to the initial context. Then you need to use / not \ in the name string. Then you need to take whatever steps are required to ensure that whatever you are looking for by that name has been bound in the naming service with that name.
  • 2. Re: Connetct to JNDI
    807600 Newbie
    Currently Being Moderated
    Yes, you are right =) I've made a mistake....

    You whould be laughing but ... What I had to do is just add JBoss lib to my client project =) Now it works !

    Thanks for you help!