Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Help needed ....NoInitialContextException

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write my first Stateless session bean...
i have written the approp interfaces and the bean class and deployed the ear successfully
i have written the following code but am getting the same exception that u were getting
"Exception in thread "main" javax.naming.NoInitialContextException"
could uu please suggest me some solution!!!
here's the Client Code
package examples;
import java.util.Properties ;
import javax.naming.Context ;
import javax.naming.InitialContext ;
public class HelloClient {
public static void main( String [] args ) throws Exception {

Properties h = new Properties();

h.put( Context.INITIAL_CONTEXT_FACTORY, "" ) ;
h.put( Context.PROVIDER_URL, "iiop:///" ) ;
Context ctx = new InitialContext(h) ;

Object obj = ctx.lookup( "HelloWorld") ;
HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow( obj, HelloHome.class ) ;
Hello hello = home.create() ;
System.out.println( "Output from EJB: " + hello.hello() ) ;
hello.remove() ;
Thanx & Regards,
Priyank Patwa.
Cognizant Technology Solutions India Pvt. Ltd.
Infotech Park,
Pune 411027,
Ph. 2931100 extn: 2476
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

h.put( Context.PROVIDER_URL, "iiop:///" ) ;

You have not specified the host name.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic