Hi All,
I have just started reading Manning -EJB3 in Action and am trying to make a working eg .
I am using JBoss4.2.3GA and MyEclipse5.1 .
The step I followed were:
Step 1.Create a remote interface "HelloUser.java"
Step 2.Create a stateless bean "HelloUserBean.java"
these two are listed as :
"HelloUser.java"
package com.ejb3inaction.actionbazaar.buslogic;
import javax.ejb.Remote;
@Remote
public interface HelloUser {
public void sayHello(
String name);
}
"HelloUserBean.java"
package com.ejb3inaction.actionbazaar.buslogic;
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!");
}
}
Step 3.Deployed the application through MyEclipse on to the
Jboss server .
Step 4.Started the JBoss server
Step5.Created a client class "HelloUserClient" listed below
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("chapter1/"
+ HelloUserBean.class.getSimpleName() + "/remote");
helloUser.sayHello("Obama ");
} catch (NamingException e) {
e.printStackTrace();
}
}
}
All classes compiled OK and showed no eror message/warnings.
The error message that I get on Running "HelloUserClient" as a stand alone application is :
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.ejb3inaction.actionbazaar.client.HelloUserClient.main(HelloUserClient.java:16)
I cant figure out how to remove this error ,did I miss a step some where ,please do explain.
Also I am new at JBoss server , so I cant confirm if the application was actually deployed
on the server or not.
Thanks a lot for helping (and going through such a big post
)