【发布时间】:2011-11-25 19:31:18
【问题描述】:
我正在尝试在我的 Spring 应用程序中实现 JMS。我在 applicationContext.xml 中定义了 JNDI 名称 + 队列名称如下:
<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>
现在我的控制器使用以下代码调用 emailSender bean:
ApplicationContext context = new ClassPathXmlApplicationContext("/applicationContext.xml");
EmailSender sender =(EmailSender)context.getBean("emailSender");
我得到的异常是:错误 404:请求处理失败;嵌套异常是 org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml];嵌套异常为 java.io.FileNotFoundException: 类路径资源 [applicationContext.xml] 无法打开,因为它不存在
我在 serevr 启动时加载 applicationContext.xml,但我的代码仍然无法找到此文件。
有人可以帮忙吗??
【问题讨论】:
标签: spring model-view-controller jms jndi