10 Replies Latest reply on Aug 29, 2013 12:59 PM by billhmoore

    Using Hornetq within the same JBOSS AS.


      I am using JBOSS 7.1 where I have defined a topic has been defined.  I also have a webapp that will publish a message to that topic.  In the publisher, I have the following code:


          // Create Properties.
         Properties props = new Properties();
         props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
         //props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
         props.put(Context.PROVIDER_URL, providerUrl);
         props.put(Context.SECURITY_PRINCIPAL, username);
         props.put(Context.SECURITY_CREDENTIALS, password);
         props.put("jboss.naming.client.ejb.context", true);


         // Create an initial context.
         context = new InitialContext(props);

      When the "new InitialContext(props)" is invoked, I get the following error:


      07:59:28,377 ERROR [stderr] (MSC service thread 1-13) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.accountTransfer-webapp.war:main" from Service Module Loader


      07:59:28,379 ERROR [stderr] (MSC service thread 1-13)     at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)


      07:59:28,380 ERROR [stderr] (MSC service thread 1-13)     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:664)


      07:59:28,381 ERROR [stderr] (MSC service thread 1-13)     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)


      07:59:28,382 ERROR [stderr] (MSC service thread 1-13)     at javax.naming.InitialContext.init(InitialContext.java:223)


      07:59:28,383 ERROR [stderr] (MSC service thread 1-13)     at javax.naming.InitialContext.<init>(InitialContext.java:197)



      While the code works when I start a separate application, it does not work within my webapp.


      How can does this work from a webapp in the same JBOSS AS?