Created
February 23, 2012 13:57
-
-
Save mpellegrini/1892975 to your computer and use it in GitHub Desktop.
Remote JNDI Support in JBoss AS 7.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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