Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NameNotFound Exception

 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am in the first chapter of HFEJB book. I get a 'nameNotFound' Exception when I try to run the client program.

import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import hf.AdviceHome;
import hf.Advice;
import java.rmi.*;
import javax.ejb.*;
import java.util.*;

public class AdviceClient{


public static void main(String args[]){

new AdviceClient().go();
}

public void go(){

try{




Context ic = new InitialContext();
//Object o = ic.lookup("TEST");




AdviceHome ac = (AdviceHome)PortableRemoteObject.narrow(ic.lookup("TEST"),AdviceHome.class);



Advice adcomp = ac.create();
System.out.println(adcomp.getAdvice());
}
catch(Exception e)
{
e.printStackTrace();
//System.out.println(e.getMessage());
}


}//end of method



}

Here is the error.
======================
javax.naming.NameNotFoundException: TEST not found
<<no stack trace available>>


==========
Any thoughts on the cause?
 
makesh bala
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like, the name(TEST) that you use to look up from the client doesnt match with the JNDI lookup name you have specified for the bean when you deployed the bean.
-Makesh
 
Chetan Sahasrabudhe
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get hang of Reference Implementation by sun, try doing j2ee tutorial provided by sun. This shall help you understand how ejb related context is managed in RI.

my guess is you should put ejb/test in RI
make sure you are mapping the reference properly and then try deploying it.
 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I gave the JNDI name as 'ejb/TEST'.

As specified in the J2EE RI docs, I included this in the default-web.xml.

<ejb-ref>
<ejb-ref-name>ejb/TEST</ejb-ref-name>
<jndi-name>corbaname:iiop:localhost#ejb/TEST</jndi-name>
</ejb-ref>

My clinet source code is

import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import hf.AdviceHome;
import hf.Advice;
import java.rmi.*;
import javax.ejb.*;
import java.util.*;

public class AdviceClient{


public static void main(String args[]){

new AdviceClient().go();
}

public void go(){

try{




Context ic = new InitialContext();
//Object o = ic.lookup("TEST");




AdviceHome ac = (AdviceHome)PortableRemoteObject.narrow(ic.lookup("java:comp/env/ejb/TEST"),AdviceHome.class);



Advice adcomp = ac.create();
System.out.println(adcomp.getAdvice());
}
catch(Exception e)
{
e.printStackTrace();
//System.out.println(e.getMessage());
}


}//end of method



}

I still get a NmaNotFoundException.

Please advice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic