Thanks a lot guys ,
Got it working now with your help
.As you pointed out the trouble was that I did not have jndi.properties in classpath .
So the working solution can be listed as :
Step 1.
Create "HelloUser.java"
package com.ejb3inaction.actionbazaar;
import javax.ejb.Remote;
@Remote
public interface HelloUser {
public void sayHello(String name);
}
Step 2.
Create "HelloUserBean.java"
package com.ejb3inaction.actionbazaar;
import javax.ejb.Stateless;
@Stateless
public class HelloUserBean implements HelloUser {
public void sayHello(String name) {
System.out.println("Hello " + name + " welcome to EJB 3 In Action!");
}
}
Step3.
Created a client class "HelloUserClient"
package com.ejb3inaction.actionbazaar.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.ejb3inaction.actionbazaar.buslogic.HelloUser;
import com.ejb3inaction.actionbazaar.buslogic.HelloUserBean;
public class HelloUserClient {
private static HelloUser helloUser;
public static void main(String[] args) {
try {
Context context = new InitialContext();
helloUser = (HelloUser) context.lookup(“HelloUserBean/remote");
helloUser.sayHello("Obama ");
} catch (NamingException e) {
e.printStackTrace();
}
}
}
Step 4.
Create jndi.properties in the souce folder (src folder)
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099
Step 5.
Deploy the code ,start the server and run the client as a standalone java application.
PS:
Don’t forget to include jBossall-client.jar ,without it ClassNotFound exception is thrown .
thanks and cheers