Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

NameNotFound Exception

 
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?
 
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
 
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.
 
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic