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
Greenhorn
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) {
try
{
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
SessionHelloWorldHome home = (SessionHelloWorldHome) ctx.lookup("SessionHelloWorldHome");
SessionHelloWorld hello = home.create();
hello.Hello();
hello.remove();
}catch(Exception e)
{
e.printStackTrace();
}
}
}
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(NamingManager.java:6
40)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
a:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at SessionHelloWorld.SessionHelloWorldClient.main(SessionHelloWorldClien
t.java:27)

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

Thanks!
 
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 : http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
 
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!