开发者

JMS implementation using JNDI in spring application

I am trying to implement JMS in my spring application. I have defined the JNDI name + queue name in applicationContext.xml as follows:

<bean id="emailQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName" value="java:comp/env/jms/<<Name of JNDI of connection factory>>" />
</bean>

<bean id="emailQueueDestination" class="org.springframework`enter code here`.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName" value="java:comp/env/jms/<<JNDI name of queue>>" />
</bean>

<bean id="emailQueueTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
<property name="connectionFactory" ref="emailQueueConnectionFactory" />
<property name="defaultDestination" ref="emailQueueDestination" />
</bean>

<bean id="emailSender" class="<<Package>>.EmailSender" lazy-init="true">
<property name="jmsTemplate">
<ref bean="emailQueueTemplate" />
</property>
</bean>

Now my controller makes a call to the emailSender bean using the following code:

ApplicationContext context = new ClassPathXmlApplicationContext("/applicationContext.xml");
EmailSender开发者_如何学JAVA sender =(EmailSender)context.getBean("emailSender");

The exception I get is: Error 404: Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

I am loading the applicationContext.xml at serevr start-up still my code is not able to locate this file.

Can anyone please help.??


make sure your applicationContext.xml file is in your class path then add the class path prefix, You can try some thing like this

   ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜