I am having problems using a stand alone program. 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.RemoteInitialContextFacto
ry
java.naming.provider.url=localhost:4201
Does anyone have any thoughts?
Thank you,
Jeremy