It is a J2EE app but run outside of the container. A swing app that will access the Geronimo server remotely. I guess my use of "stand alone" was not correct. How does a user execute the ear client module?

Jeremy

On Sep 2, 2008, at 1:50 PM, David Jencks wrote:


On Sep 2, 2008, at 5:40 AM, Jeremy Cowgar wrote:

I am having problems using a stand alone program.

Injection only works with jee app clients, typically deployed as a client module in an ear. I wouldn't describe these as "stand alone"

thanks
david jencks


I have the following code:

public class Main {
        @EJB
        private GreeterRemote greeter;
        
        public static void main(String[] args) {
                new Main();
        }

        public Main() {
                System.out.println(greeter.getGreeting("Jeremy"));
        }

}

greeter is always null. If I provide an initial context and do the lookup myself, it works as expected:

public class Main {
        private GreeterRemote greeter;
        
        public static void main(String[] args) {
                new Main();
        }

        public Main() {
                super();

                try {
                        InitialContext ic = new InitialContext();
                        greeter = (GreeterRemote) ic.lookup("GreeterRemote");
                        System.out.println(greeter.getGreeting("Jeremy"));
                } catch (NamingException e) {
                        e.printStackTrace();
                }
                
        }

}

For the InitialContext() one to work, I have supplied a jndi.properties file:

java.naming.factory.initial=org.openejb.client.RemoteInitialContextFa ctory
java.naming.provider.url=localhost:4201

Does anyone have any thoughts?

Thank you,

Jeremy



Reply via email to