Hi,
We've written a java client to access a permissioned EJB, and therefore we are using the initialcontext factory Jndi/LoginInitialcontextFactory.
Our client works when we follow the example in links
http://wiki.jboss.org/wiki/Wiki.jsp?page=LoginInitialContextFactory
http://wiki.jboss.org/wiki/Wiki.jsp?page=JndiLoginInitialContextFactory
that is we have explicitly passed in a properties object to the constructor
e.g.
Properties env = new Properties();
// Try with a login that should succeed
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
env.......
Initialcontext ctx = new InitialContext(env);
However, when we try to initialize the InitialContext solely via the environment we get a null pointer exception (looking at the line number and the code, it seems the principal is null).
Hence, the following call doesn't work, assuming no jndi file in classpath, just -D options passed):
Initialcontext ctx = new InitialContext();
I'm using the following properties....
-Djava.naming.factory.initial
-Djava.naming.provider.url
-Djava.naming.security.principal
-Djava.naming.security.credentials
-Djava.naming.security.protocol
-Djava.security.auth.login.config
We can get round the problem with the following call, however, it's not ideal:
InitialContext ctx = new InitialContext(System.getProperties());
Can anyone think of anything obvious?