• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I solve NameNotFoundException?

 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I got the javax.naming.NameNotFoundException : AdviceBean in my ejb local client I have given the complete program below.

import javax.naming.*;
import java.util.*;

public class AdviceClient
{
public static void main(String[] args)
{
try
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
p.put(Context.PROVIDER_URL,"file:///e:/kramesh-java/ejb/Advice-EJB/classes/headfirst"); //1099
Context context = new InitialContext(p);
Object o=context.lookup("AdviceLocalHome");
System.out.println("home object has been brought");
AdviceLocalHome home=(AdviceLocalHome)o;
AdviceLocal advice=home.create();
System.out.println(advice.getAdvice());
}
catch(Exception ex)
{
ex.printStackTrace();
//System.out.println(ex);
}
}
}

I have the component interface "AdviceLocal"
the home interface "AdviceLocalHome"
the bean implementation class "AdviceBean"

we do the lookup for home interface "AdviceLocalHome".if so, what is the JNDI name for "AdviceLocalHome"?Are the home interface class name and the JNDI name same?How to set JNDI name in netbeans IDE for local home interface and make the lookup?

help me solve this long time problem.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the home interface class name and the JNDI name same?

No, it can be any name. The thing referred by that name must be the home interface.
 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satou ,

Thank you for reply.I want to know how we can set JNDI name and refer it in client coding.I got NameNotFoundException.please give me the solution.

Thanks and RagardS,
Ramesh
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using J2EE RI, with the RI deploytool, you can specify the JNDI name when deploying. Don't know about other tools.
 
Sunil Dixit
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rakesh,
Could you please tell me which application server you are using?
and I think you are missing one property to set.
Normally we need to set three properties which are
1. Context.INITIAL_CONTEXT_FACTORY
2. Context.PROVIDER_URL
3. Context.URL_PKG_PREFIXES

and make it sure that jnpallclient.jar should be in your classpath.

Cheers,
Sunil
 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sunil,
Thanks for your reply.I use sun java app server 8.2.Where can I get that "jnpallclient.jar".what is the requirement for that jar file?I am being affected by this JNDI problem for months.please help me to solve it?

thanks and regards,
Ramesh kangamuthu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!