MVC项目交谈

时间:2013-09-17 23:16:24

标签: spring-mvc

我正在使用带有Spring STS 3.1.0的Eclipse Juno。我在同一个工作区有2个mvc项目。其中一个项目可以发送和接收jms消息。它使用Spring JmsMessagListener bean来接收消息。 bean使用onMessage方法映射到侦听器类。当我在VMWare tc服务器上运行带有jms的项目时,我每隔5秒在控制台中收到以下消息:

警告:org.springframework.jms.listener.DefaultMessageListenerContainer - 无法刷新目标“mht.alert.queue”的JMS连接 - 在5000毫秒内重试。原因:无法连接到代理URL:tcp:// localhost:61616。原因:java.net.ConnectException:连接超时:连接

该项目似乎正在尝试连接到我的activemq代理,该代理未运行,因为我没有运行内置jms的项目。我不明白为什么会发生这种情况。我已经包含了两个项目的web.xml文件。希望有人可以告诉我为什么会发生这种情况。它不是一个showstopper,因为我可以忽略这些消息或让经纪人让他们保持沉默,但是最好还是妥善处理它。

提前致谢

以下是没有jms的项目的web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns
   /javaee/web-app_3_0.xsd">

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<listener>
<listenerclass>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

以下是内置jms的项目的web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
               http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">


<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml, 
                 /WEB-INF/spring/jms-config.xml, 
                 /WEB-INF/spring/security-config.xml,
                 /WEB-INF/spring/datasource-tx.xml
     </param-value>
</context-param>


<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>    

<!--<start id="filter_security" /> -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>
        org.springframework.web.filter.DelegatingFilterProxy
    </filter-class>
</filter>
<!--<end id="filter_security" />-->

<!--<start id="filter_mapping_security" /> -->
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<!--<end id="filter_mapping_security" />-->

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- This servlet is mapped to all requests at the root level -->
<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

以下是我的root-context.xml的内容,而不是注释掉spring-security.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.1.xsd
   http://www.springframework.org/schema/tx 
   http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

<!-- Root Context: defines shared resources visible to all other web components -->

    <!-- Import the datasource-tx.xml file to configure the StudentDao service and make
     it visible to the entire application
  -->
<import resource="classpath:datasource-tx.xml" />
<!-- <import resource="spring-security.xml" /> -->

</beans>

0 个答案:

没有答案