I'm trying to lookup for the JBoss Mail connection factory from a standalone program (I mean something that doesn't run in the JBoss VM). The Mail-Connection-Factory jndi name is bound to "java:/Mail". However, I always get a 'javax.naming.NameNotFoundException: Mail not bound' message, but it works within the Jboss VM.
My client jndi.properties file looks like:
And, I simply wrote :
InitialContext ctx = new InitialContext();
Object oMail = ctx.lookup("java:/Mail");
So, Why can't I find the mail factory outside Jboss?
Right. The Java context is only for in same JVM. So "java:/Mail" will never work outside JVM. You need to use the jndi name for outside the JVM. Do a dump of Jndi from the jmx console to see how its bound for outside JVM.