[jboss-user] [EJB 3.0] - [Beginner] Remote Client Dependency Injection doesn't work..
francis1970
do-not-reply at jboss.com
Wed Jan 9 10:15:06 EST 2008
Hi all !
I have found an EJB 3 example from Oracle site, it uses dependency injection to invoke the EJB. Unfortunately it doesn't work on JBoss....I get a "NullPointerException" when I invoke the sayHello method.
Added also Context information but still doesn't work.
Do I need to add some configuration file to the EJB's jar file so that dependency injection works ???
This is the EJB
package oracle.ejb30;
|
| import javax.ejb.Remote;
| @Remote
| public interface HelloWorld {
| public void sayHello(String name);
| }
|
| -----------------------------------------------------
| package oracle.ejb30;
|
| import javax.ejb.Stateless;
|
| @Stateless
| public class HelloWorldBean implements HelloWorld {
| public void sayHello(String name) {
| System.out.println("Hello " + name
| + " from your first EJB 3.0 component ...");
| }
| }
| -------------------------------------------------------
| package oracle.ejb30;
|
| import javax.ejb.EJB;
| import java.util.*;
| import javax.naming.*;
|
| public class HelloWorldClient {
| @EJB
| private static HelloWorld helloWorld;
|
| public static void main(String[] args) throws NamingException {
| Properties env = new Properties();
| env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| env.setProperty("java.naming.provider.url", "localhost:1099");
| env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
| Context ctx = new InitialContext(env);
|
| System.out.println("Using Dependency Injection .. invoking sayHello ");
| helloWorld.sayHello("Debu Panda!");
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118315#4118315
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118315
More information about the jboss-user
mailing list