users@glassfish.java.net

EJB 3.0 NullPointerException wiht Dependency Injection

From: <glassfish_at_javadesktop.org>
Date: Tue, 18 Mar 2008 13:38:47 PST

Hello every one,

i try (since several days) to develop some basics Javaee Enterprise Applications using NetBeans 6.0 and EJB 3.0 specially the dependency injection features. Unfortunely, the injection don't work, so that i always get a NullPointerException. Even when i try just to deploy sun delivered samples in Glassfish for instance, then i always have the same problem.

Here ist a code sample:

--
package confirmer.client;
import confirmer.ejb.Confirmer;
import javax.ejb.EJB;
/**
 *
 * @author ie139813
 */
public class ConfirmerClient {
    @EJB
    private static Confirmer confirmer;
    /** Creates a new instance of ConfirmerClient */
    public ConfirmerClient() {
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String recipient = null;
        if (args.length == 1) {
            recipient = args[0];
        } else {
            recipient = "pig.bodine_at_example.com";
        }
        try {
            confirmer.sendNotice(recipient);
            System.out.println("Message sent to " + recipient + ".");
            System.exit(0);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
---
The Confirmer class is a stateless session Bean Interface. There is an implementing Class named ConfirmerBean in the Enterprise Application.
Please, could somebody help me? I would be very greatful.
Cheers.
loopman
[Message sent by forum member 'loopman' (loopman)]
http://forums.java.net/jive/thread.jspa?messageID=264683