Community

problems with JNDI in AS 6 M3

created by marc torrent in JNDI and Naming - View the full discussion

Hello,

 

I'm facing a problem with JNDI and JBoss. I've developed a webapp for tomcat6, that, among other things, uses JNDI to put messages in an activeMQ queue. To configure JNDI with tomcat I put inside META-INF/context.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TranscodingGateway" docBase="TranscodingGateway" debug="0" reloadable="true">
    <Resource
          name="jms/ConnectionFactory"
          auth="Container"
          type="org.apache.activemq.ActiveMQConnectionFactory"
          description="JMS Connection Factory"
          factory="org.apache.activemq.jndi.JNDIReferenceFactory"
          brokerURL="tcp://localhost:61616"
          brokerName="localhost"
          usejmx="false"
          useDatabaseLock="false"
          useEmbeddedBroker="false" />
    <Resource
          name="jms/Transcoding"
          auth="Container"
          type="org.apache.activemq.command.ActiveMQQueue"
          factory="org.apache.activemq.jndi.JNDIReferenceFactory"
          physicalName="Transcoding" />
</Context>

 

and nothing extra in web.xml

 

Also, the java code is like:

 

......................

            InitialContext ic = new InitialContext();
            Context ctx = (Context) ic.lookup("java:comp/env");
            ConnectionFactory cf = (ConnectionFactory)
            ctx.lookup("jms/ConnectionFactory");
            Connection conn = (Connection) cf.createConnection();
            conn.start();
            Session s = conn.createSession(false,Session.CLIENT_ACKNOWLEDGE);
            Destination d = (Destination) ctx.lookup("jms/Transcoding");
            MessageProducer mp = s.createProducer(d);
            mp.setDeliveryMode(DeliveryMode.PERSISTENT);

..........................

 

With this configuration works fine with tomcat standalone, but not in JBoss. The deployer doesn't say any error, but when executing the code it fails at line:    ctx.lookup("jms/ConnectionFactory");

 

the log:  http://pastebin.com/1rmVTWz3

 

If I make a change inside web.xml and add:

 

<resource-env-ref>
    <description>
     ActiveMQ ConnectionFactory
    </description>
    <resource-env-ref-name>
     jms/ConnectionFactory
    </resource-env-ref-name>
    <resource-env-ref-type>
     org.apache.activemq.ActiveMQConnectionFactory
    </resource-env-ref-type>
   </resource-env-ref>
  
   <resource-env-ref>
    <description>
     ActiveMQ Queue
    </description>
    <resource-env-ref-name>
     jms/Transcoding
    </resource-env-ref-name>
    <resource-env-ref-type>
     org.apache.activemq.command.ActiveMQQueue
    </resource-env-ref-type>
   </resource-env-ref>

 

 

 

I get the following error at deployment:

 

http://pastebin.com/YyNqWa4b

 

 

Any ideas? As I've read, context look up can be done inside context.xml of the application. What I'm doing wrong, or what am I missing to do?

 

thank's!

Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community