Skip to content

Instantly share code, notes, and snippets.

@mpellegrini
Created February 23, 2012 13:57
Show Gist options
  • Save mpellegrini/1892975 to your computer and use it in GitHub Desktop.
Save mpellegrini/1892975 to your computer and use it in GitHub Desktop.
Remote JNDI Support in JBoss AS 7.1
// Create an initial context to perform the JNDI lookup.
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
env.put(Context.PROVIDER_URL, "remote://localhost:4447");
env.put(Context.SECURITY_PRINCIPAL, "username");
env.put(Context.SECURITY_CREDENTIALS, "password");
Context context = new InitialContext(env);
// JNDI Lookups
ConnectionFactory cf = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
Queue queue = (Queue) context.lookup("jms/queue/test");
/*
** In order for an object to be reachable in jndi from outside the server,
** it must be registered under <code>java:jboss/exported/</code> context.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment