Skip to main content

how to bind JMS connection factory/queue in web.xml?

3 replies [Last post]
classfish
Offline
Joined: 2008-07-17
Points: 0

Hi,

I'm trying to define a JMS connection factory and a message queue for my web component. I tried something like this in the web.xml:

Default JMS Connection Factory
jms/jwangConnectionFactory
javax.jms.ConnectionFactory
Container

Default JMS Queue Destination
jms/jwangMsgQueue
javax.jms.Queue
Container

I also have tried to define the repective elements in "sun-web.xml" as well. That is, both "web.xml" and "sun-web.xml" are defined.

My web app log shows this error:
"javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/jwangConnectionFactory"

The connection factory and queue were defined via the admin web interface.

Injection with annotation @Resource(mappedName="jms/jwangConnectionFactory") into one of the EJB was working fine.

The ejb ref and jdbc datasource defined in the same web.xml were working fine.

My question:
1, which element it should use to define a JMS resource? "resource-ref" or "resource-env-ref"(not working either) or something else?
2, why it's not working in my example.

Thanks for your help

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
djiao
Offline
Joined: 2003-09-03
Points: 0

Hi, classfish,

I can see one problem in your web.xml:

You should use for JMS Connection Factories, and use for Queues and Topics, based on JMS spec.

Since your problem is with JMS Connection Factory, so there must be something else going on as well. But I can't tell from your email. What does your sun-web.xml look like?

djiao

classfish
Offline
Joined: 2008-07-17
Points: 0

thanks djiao,

I've actually tried the for both connection factory and the queue and it was not working.

regarding the sun-web.xml, i did not define anything in it in the beginning. since it's not working, i defined corresponding entries for the connection factory and queue. like:


jms/jwangConnectionFactory
jms/jwangConnectionFactory


jms/jwangMsgQueue
jms/jwangMsgQueue

however, it's still not working. it kept saying that the object was not bound:
javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/jwangConnectionFactory

djiao
Offline
Joined: 2003-09-03
Points: 0

Hi, classfish,

The sun-web.xml has one thing wrong. Use for the Queue.

But again, you have problem with ConnectionFactory, not Queue. But give it a try with correct web.xml and sun-web.xml, hopefully it solves your problem.

djiao