Author |
Message
|
saranj |
Posted: Mon Nov 26, 2007 1:20 pm Post subject: How to define MQ QueueConnectionFactory in spring using JNDI |
|
|
Newbie
Joined: 07 Nov 2007 Posts: 7
|
Hi all,
I have created MQ Connection factory and MQ Queue on WAS thru admin console.
I am trying to define these information on Spring configuration file. here is my spring file.
[code]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="msgSender"
class="com.hermes.dataaccess.esr.jms.MessageSender " >
<property name="jmsTemplate">
<ref bean="jmsQueueTemplate"/>
</property>
</bean>
<bean id="msgReceiver"
class="com.hermes.dataaccess.esr.jms.MessageReceiv er">
</bean>
<!-- mq Queue Connection Factory -->
<bean id="internalJmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName">
<value>jms/HermesCF</value>
</property>
</bean>
<bean id="destinationQueue" class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName">
<value>jms/DeliveryQueue</value>
</property>
</bean>
<!-- JMS Template -->
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref local="internalJmsQueueConnectionFactory" />
</property>
<property name="defaultDestination">
<ref bean="destinationQueue"/>
</property>
</bean>
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
<property name="concurrentConsumers" value="1"/>
<property name="connectionFactory" ref="internalJmsQueueConnectionFactory"/>
<property name="destination" ref="destinationQueue" />
<property name="messageListener" ref="msgReceiver"/>
<property name="sessionTransacted" value="true"/>
</bean>
</beans> [/code]
While running the server, am getting the following error.
[code]
11/26/07 16:07:08:359 EST] 00000047 ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'msgSender' defined in ServletContext resource [/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Cannot resolve reference to bean 'jmsQueueTemplate' while setting bean property 'jmsTemplate'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jmsQueueTemplate' defined in ServletContext resource [/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Cannot resolve reference to bean 'internalJmsQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'internalJmsQueueConnectionFactory' defined in ServletContext resource [/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: PSILAP01Node01Cell/nodes/PSILAP01Node01/servers/server1, name: jms/HermesCF: First component in name HermesCF not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0]
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jmsQueueTemplate' defined in ServletContext resource [/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Cannot resolve reference to bean 'internalJmsQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'internalJmsQueueConnectionFactory' defined in ServletContext resource [/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: PSILAP01Node01Cell/nodes/PSILAP01Node01/servers/server1, name: jms/HermesCF: First component in name HermesCF not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0]
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'internalJmsQueueConnectionFactory' defined in ServletContext resource [/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: PSILAP01Node01Cell/nodes/PSILAP01Node01/servers/server1, name: jms/HermesCF: First component in name HermesCF not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0]
Caused by: javax.naming.NameNotFoundException: Context: PSILAP01Node01Cell/nodes/PSILAP01Node01/servers/server1, name: jms/HermesCF: First component in name HermesCF not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0
at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_ resolve_complete_info(WsnOptimizedNamingImpl.java: 543)
at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBa se.resolve_complete_info(WsnOptimizedNamingImplBas e.java:2213)
at com.ibm.WsnOptimizedNaming._NamingContextStub.reso lve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve (CNContextImpl.java:4043)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(C NContextImpl.java:1746)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(C NContextImpl.java:1707)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt( CNContextImpl.java:1412)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNC ontextImpl.java:1290)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCt x.java:145)
at javax.naming.InitialContext.lookup(InitialContext. java:361)
at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:123)
[/code]
Am i missing anything on Spring configuration file ? Pls help me.
Thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 26, 2007 6:51 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
[/WEB-INF/classes/hermesweb/com/hermes/spring/spring.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: |
Has the proper JNDI context been created on WAS BEFORE starting the application and has the WAS instance been restarted to take advantage of that context??  _________________ MQ & Broker admin |
|
Back to top |
|
 |
saranj |
Posted: Tue Nov 27, 2007 11:30 am Post subject: |
|
|
Newbie
Joined: 07 Nov 2007 Posts: 7
|
Hi Saper,
Thanks for your reply. I've found out the issue...I've created queue connection factory and queue at the NODE level on WAS but context was pointing to Server level ALWAYS.
Once i created connection and queue under server level , everything worksfine. but i wanted to have connection factory and queue at the CELL level.
how can i do that ? anyone have any information.
[quote]
Caused by: javax.naming.NameNotFoundException: Context: [b]PSILAP01Node01Cell/nodes/PSILAP01Node01/servers/server1[/b], name: jms/HermesCF: First component in name HermesCF not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0
[/quote] |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Nov 27, 2007 11:33 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Name resolution should propagate up through server, node, and cell.
Was nodeagent and dmgr running at the time? They have to be, to respond to JNDI requests for node & cell context. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
JLRowe |
Posted: Thu Nov 29, 2007 2:16 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
Perhaps you created the resource at the deployment manager node level? not the node hosting your server.
JNDI definitions propagate downwards, so a node level definition is available to all servers on the cell.
The JNDI tree is replicated, so it doesn't matter if the node agent or dmgr are down. |
|
Back to top |
|
 |
matpil |
Posted: Mon Feb 04, 2008 4:32 am Post subject: configure spring |
|
|
Newbie
Joined: 04 Feb 2008 Posts: 2
|
it's possible to configure spring to call a backout function? |
|
Back to top |
|
 |
|