Hello All,
Im very new to
EJB 3. I was trying to run a very simple SessionBean, and Im getting the NullPointerException. The code are as follows:
BeanClass(serverpack.BeanClass)
--------------------------------
package serverpack;
import javax.ejb.Stateless;
@Stateless
public class BeanClass implements BeanInterface {
public void message() {
System.out.println("Hello World");
}
}
Component Interface(serverpack.BeanInterface)
----------------------------------------------
package serverpack;
import javax.ejb.Remote;
@Remote
public interface BeanInterface {
void message();
}
I compiled these two classes successfully, added them to myapp.ear and deployed them in the GlassFish server.
I wrote a client class, which is as follows:
Client Class: (clientpack.BeanClient)
-------------------------------------
package clientpack;
import javax.ejb.EJB;
import serverpack.*;
public class BeanClient {
@EJB
private static BeanInterface bInterface;
public static void main(
String... args) {
bInterface.message();
}
}
When I tried to run this from the command line, I got a NullPointerException. Im sure Im missing some step. Could anyone of you please guide me through this?
Kind Regards,
Rakesh.R
SCJP 6, SCWCD 5.