Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error when accessing statefull session bean pg 219  RSS feed

laxmi varun
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the client code

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet pa
rameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.go(
at AdviceClient.main(

This is my client code

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient {

public static void main(String[] args){
new AdviceClient().go();

public void go() {
try {
Context ic = new InitialContext();
System.out.println(" lookup");
Object o = ic.lookup("AdvisorStateful");
System.out.println(" getting home");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o,AdviceHome.class);
System.out.println(" got home");
Advice advisor = home.create("clover");


catch (Exception ex)

I got this from the sun-j2ee-ri.xml of the client jar I created using SUN RI
JNDI name is correct

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE j2ee-ri-specific-information PUBLIC '-//Sun Microsystems Inc.//DTD J2EE Reference Implementation 1.3//EN' 'http://localhost:8000/sun-j2ee-ri_1_3.dtd'>

<rolemapping />
<b> <jndi-name>AdvisorStateful</jndi-name> </b>

I am runing xp prof java 1.4. Did anyone get this error too ?

Laxmi V
Keerthi P
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This problem has been addressed here numerous times. Please do a search to see relevant posts in this forum.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!