Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How To provide Initial Context in ejb client program deployed in J2EE 1.4 SDK  RSS feed

sai Narayan
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi! this is my code for helloClient Program using an implementation of EJB:-
code for HelloClient

package SessionHelloWorld;

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

public class SessionHelloWorldClient {

public static void main(String[] args) {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
SessionHelloWorldHome home = (SessionHelloWorldHome) ctx.lookup("SessionHelloWorldHome");
SessionHelloWorld hello = home.create();
}catch(Exception e)
when i try to run the above code i get the folloeing error:-
C:\HelloWorld>java SessionHelloWorld.SessionHelloWorldClient
javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource f
ile: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
at javax.naming.InitialContext.lookup(
at SessionHelloWorld.SessionHelloWorldClient.main(SessionHelloWorldClien

Can anybody please explain me how to provide InitialContext while using J2ee 1.4 Sdk?

PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem could well be because the props object doesnt have the required properties set.

Refer to the following link :
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!