File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 916

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: 9317
    
109

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
 
Similar Threads
Error while trying to run StatelessSessionBean
EJB simple client is not running
NullPointerException while using DI
Client not calling ejb method!!!
NullPointer Exception in EJB 3.0