• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax. naming. NoInitialContextException

 
jo star
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to run a simple helloworld session bean example using JBOSS4
when I try to run HelloClient.java it gives following error

D:\EJBexamples\assemble>java -classpath helloclient.jar;%LIBDIR%\jnp-client.jar;%LIBDIR%\jboss-common-client.jar;%LIBDIR%\jboss-j2ee.jar;%LIBDIR%\jboss-net-client.jar;%LIBDIR%\jbossall-client.jar;;%LIBDIR%\jnet.jar com.examples.HelloClient

Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, 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 com.examples.HelloClient.main(HelloClient.java:13)


following is the code for my HelloClient class

package com.examples;

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

public class HelloClient
{
public static void main (String[] args) throws Exception
{
Context c = new InitialContext();
Object o = c.lookup ("Hello");

HelloHome home =
(HelloHome)PortableRemoteObject.narrow (o,HelloHome.class);
Hello hello = home.create();
System.out.println (hello.sayHello());
hello.remove();
}
}


can some body tell me what is going wrong !!

Thanks in advance.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set properties something like this below(check your server document, because this will change server to server) and then instantiate your IntitalContext.



hth,
 
jo star
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was able to solve the issue.
thanks a lot for your quick help

regards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!