1 Reply Latest reply on Nov 11, 2014 7:38 AM by Jochen Cordes

    Creating a JMS client with diferent JNDI

    Rafael Chavez Newbie

      Hi there, im trying to deploy my ear in jboss 6.2 but i have a problem with the JNDI of my connection factory and the queues. I found an example of a helloworld-jms, and i try ti test my queues. When i try the first queue, i found that the prefix where jboss are executing the lookup is on java:/jboss/exported/MyQueue, but i dont want to use this prefix, i want only java:/MyQueue. This is how im trying to connect:

       

      private static final String DEFAULT_CONNECTION_FACTORY = "MyConnectionFactory";

          private static final String DEFAULT_DESTINATION = "MyQueue";

          private static final String DEFAULT_MESSAGE_COUNT = "1000";

          private static final String DEFAULT_USERNAME = "jbossadmin";

          private static final String DEFAULT_PASSWORD = "hithere31!";

          private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";

          private static final String PROVIDER_URL = "remote://localhost:4447";

          private static final String JNP_INTERFACES = "org.jboss.naming:org.jnp.interfaces";

       

      try {

                  // Set up the context for the JNDI lookup

                  final Properties env = new Properties();

                  env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

                  env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));

                  env.put(Context.URL_PKG_PREFIXES, JNP_INTERFACES);

                  env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));

                  env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));

                  context = new InitialContext(env);

       

                  // Perform the JNDI lookups

                  String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);

                  log.info("Attempting to acquire connection factory \"" + connectionFactoryString + "\"");

                  connectionFactory = (ConnectionFactory) context.lookup("MyConnectionFactory");

                  log.info("Found connection factory \"" + connectionFactoryString + "\" in JNDI");

       

                  String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);

                  log.info("Attempting to acquire destination \"" + destinationString + "\"");

                  destination = (Destination) context.lookup("MyQueue");

                  log.info("Found destination \"" + destinationString + "\" in JNDI");

       

      and always try the lookup on jboss.naming.context.java.jboss.exported. Can you help me?? thanks!