1 Reply Latest reply on May 5, 2013 4:57 PM by wolfch

    Cannot map java:/JmsXA to web app resource as java:comp/env/jms/JmsXA

    chris.wolf Newbie



      This is my first post.  I want to use a JMS ConectionFactory via a Resource Adapter, therefore I want the CF bound to "java:JmsXA".  I want to access this from a web application, but it cannot "see" this (returns null upon attempt to lookup).  I don't understand why this is an issue since the web app is in the same VM as the JBoss server.  I wonder if there are other isolation mechanisms to consider for web apps accessing the "java:" namespace?


      I know that "JmsXA" can be reconfigured to be in the global namespace, but that will impact other applications on the server that expect it in the "java:" namespace, so that's not an option.


      Then I read how these resources can be mapped into a web app's private ENC namespace:




      So in my WEB-INF/web.xml, I put:








      ...and in WEB-INF/jboss-web.xml, I put:


      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-web xmlns:xs="http://www.jboss.org/j2ee/schema" version="5.1"









      Then in the web app code I tried to do a lookup for "java:comp/env/jms/JmsXA" but it returned null.


      How can web app code access java:JmsXA??


      I already searched this forum and FAQs, e.g.





      but there's no info on web app code accessing java:JmsXA.


      If I re-package my code as a Spring deployment and deploy using "Snowdrop", then the same code works and can access "java:JmsXA", but I'd rather

      depoy as a web app.




      Oh and it's JBoss-6.1.0  due to legacy apps, we have to stick with this old realease for now.





        • 1. Re: Cannot map java:/JmsXA to web app resource as java:comp/env/jms/JmsXA
          wolfch Newbie

          Ok, I gave up on trying to access "java:/JmsXA" from a web app deployment, however I came up with a solution that works. Just make a copy of the connection-factory configuration for "java:/JmsXA" but map this second one to a JNDI name in the global namespace.


          Here is the detailed procedure.

          ===================== deploy/hornetq/jms-ds.xml ============

          Since the JCA RA pooled JMS ConnectionFactory is mapped to "java:/JmsXA" and, for some reason, the "java:" namespace is not accessable from web applications - we  will configure another connection factory and map it in the global namespace.  The raw XAConnectionFactory is mapped to the global name "/ConnectionFactory", but JBoss does not recommend usage by applications since connections and sessions are not pooled, nor automatically cleaned up.


          As such, we need to configure an additional JCA RA pooled JMS ConnectionFactory

          Edit $JBOSS_HOME/server/default/deploy/hornetq/jms-ds.xml and add the following entry:

              <config-property name="SessionDefaultType" 
              <config-property name="JmsProviderAdapterJNDI" 
              <!-- following configured in conf/login-config.xml -->




          ===================== conf/login-config.xml ============

          Edit $JBOSS_HOME/server/default/conf/login-config.xml add an application login policy for the newly added JMS connection factory.  You're basically just going to  copy/paste the one for "JmsXA", then replace the two occurances of the string "JmsXA" with "JmsXAGlobal"


            <application-policy name="JmsXAGlobalRealm">
                <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
                  <module-option name="principal">guest</module-option>
                  <module-option name="userName">guest</module-option>
                  <module-option name="password">guest</module-option>
                  <module-option name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXAGlobal</module-option>


          You should now be able to do a JNDI lookup on "/JmsXAGlobal":
          JmsXAGlobal (class: org.hornetq.ra.HornetQRAConnectionFactoryImpl)