aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Error while trying to run StatelessSessionBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Reply locked New topic
Author

Error while trying to run StatelessSessionBean

Rakesh Rajagopalan
Ranch Hand

Joined: Sep 19, 2006
Posts: 59
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.
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hih Rakesh


You must run your class with an ACC application client container, otherwise the normal java ignore the adnotations.


Radards,
M.


SCJP, SCJD, SCWCD, OCPJBCD
Rakesh Rajagopalan
Ranch Hand

Joined: Sep 19, 2006
Posts: 59
Thanks for the reply. Can you please be more elaborate on the ACC? How to invoke it etc.?

Thanks,
Rakesh.R
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

Rakesh,

Please do not post the same question in multiple forums http://www.coderanch.com/t/414913/EJB-JEE/java/Error-while-trying-run-StatelessSessionBean


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while trying to run StatelessSessionBean