1 Reply Latest reply on Apr 17, 2013 6:53 AM by Somefname1 Somelname1

    Re: Can't get ConnectionFactory for JMS from JNDI when using custom security domain

    Somefname1 Somelname1 Newbie

      I'm running hornetQ JMS on jboss-as-7.2.0.Final with my custom security domain. But in JMS test I can't get ConnectionFactory. When I do not use my security domain for remoting subsystem, JMS works fine. EJB works fine with my security domain.


      I use standalone-full.xml for my test with several changes:


      1. security realm


      <security-realm name="MYRealm">


              <jaas name="mydomain"/>





      2. security domain


      <security-domain name="mydomain">


              <login-module code="my.module.MyLoginModule" flag="required" module="my.module"/>





      3.  my queue


      <jms-queue name="DemoInfoQ">

          <entry name="jms/queue/DemoInfoQ"/>

          <entry name="java:jboss/exported/jms/queue/DemoInfoQ"/>




      4. set my security realm for remoting subsystem


      <subsystem xmlns="urn:jboss:domain:remoting:1.1">

          <connector name="remoting-connector" socket-binding="remoting" security-realm="MYRealm"/>




      When I change security realm for remoting subsystem (4) to "ApplicationRealm" or nothing, JMS works. But with MYRealm my test client gives an exception, when I try to lookup ConnectionFactory:


      javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:4447]



      Why do I get such a strange error and how can I fix that? I expect some kind of security exception at least. "my.module.MyLoginModule" allows all (for test purpose), and (once again) EJB woks ok with my realm.


      I'm pretty sure that there can be no problem with my client test code, because it's pretty straightforward and it works, when I change jboss config (no sec. realm for remoting). Anyway, here it is:



      final Properties props = new Properties();


      props.put("remote.connections", "default");

      props.put("remote.connection.default.username", "any");

      props.put("remote.connection.default.password", "none");



      props.put(Context.PROVIDER_URL, providerUrl);

      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

      Context context = new InitialContext(props);

      ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");