Announcement Announcement Module
Collapse
No announcement yet.
MessageBroker already defined Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessageBroker already defined

    Does anyone know what would cause the following problem?

    Code:
    12:14:32,405 ERROR DispatcherServlet:290 - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageBroker' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = 'messageBroker'
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
            at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
            at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
            at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
            at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
            at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    Here is my setup:

    OS - ubuntu 7.04
    JVM - 1.6.0_12
    Container - tomcat 5.5.17
    Spring - 2.5.6
    Spring Flex - 1.0.0-m2
    BlazeDS - 3.2.0.3978


    web.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    	<display-name>venue-app</display-name>
    	<welcome-file-list>
    		<welcome-file>index.html</welcome-file>
    		<welcome-file>index.htm</welcome-file>
    		<welcome-file>index.jsp</welcome-file>
    		<welcome-file>default.html</welcome-file>
    		<welcome-file>default.htm</welcome-file>
    		<welcome-file>default.jsp</welcome-file>
    	</welcome-file-list>
    	
    
         <servlet>
         	<servlet-name>action</servlet-name>
         	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	 	<load-on-startup>1</load-on-startup>
         </servlet>
         
    	 <servlet-mapping>
    	 	<servlet-name>action</servlet-name>
    	 	<url-pattern>/*</url-pattern>
    	 </servlet-mapping>
    	 
    	<listener>
    		<listener-class>
    			org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    	
    	<context-param>
    	  <param-name>contextConfigLocation</param-name>
    	  <param-value>
    	    /WEB-INF/action-servlet.xml
    	  </param-value>
    	</context-param>
    
    </web-app>
    action-servlet.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	   xmlns:flex="http://www.springframework.org/schema/flex"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/flex 
               http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">        
    
    	<import resource="classpath:venue-beans.xml" />
    	<import resource="session-factory-beans.xml" />
    
    	<bean id="messageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean" >
    		<property name="servicesConfigPath" value="/WEB-INF/flex/services-config.xml" />
    	</bean>    	
    	<bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<props>
    				<prop key="/login.html">urlFilenameViewController</prop>
    				<prop key="/amf/*">messageBroker</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<bean class="org.springframework.flex.messaging.servlet.MessageBrokerHandlerAdapter"/>
    	
    	
    	<bean id="venueServiceExporter" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
    	    <property name="messageBroker" ref="messageBroker"/>
    	    <property name="service" ref="venueService"/>
    	    <property name="serviceId" value="venueService"/>
    	    <property name="includeMethods" value="getAllVenues,getVenues,createVenue,updateVenue,deleteVenue"/>
    	    <property name="channels" value="amf-channel"/>
    	</bean>	
    	
    	<bean id="sectorServiceExporter" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
    	    <property name="messageBroker" ref="messageBroker"/>
    	    <property name="service" ref="sectorService"/>
    	    <property name="serviceId" value="sectorService"/>
    	    <property name="includeMethods" value="getAllSectors,getSector,getSector,createSector,updateSector,deleteSector"/>
    	    <property name="channels" value="amf-channel"/>
    	</bean>	
    	<bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    	
    	<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    		<property name="prefix" value="/WEB-INF/jsp/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    	
    
    </beans>
    services-config.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
    	<services>
    		<service id="remoting-service" class="flex.messaging.services.RemotingService">
    	
    	    <adapters>
    	        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
    	    </adapters>
    	
    	    <default-channels>
    	        <channel ref="amf-channel"/>
    	    </default-channels>
    	    
    	</service>    	
    	
    	</services>
    	<channels>
    		<channel-definition id="amf-channel" class="mx.messaging.channels.AMFChannel">
    			<endpoint uri="http://{server.name}:{server.port}/{context.root}/amf"
    				class="flex.messaging.endpoints.AMFEndpoint" />
    			<properties>
    				<polling-enabled>false</polling-enabled>
    				<serialization>
    					<log-property-errors>true</log-property-errors>
    				</serialization>
    			</properties>
    		</channel-definition>
    	</channels>
    </services-config>
    excerpt from pom.xml

    Code:
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring</artifactId>
    			<version>2.5.6</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-webmvc</artifactId>
    			<version>2.5.6</version>
    		</dependency>		
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-flex</artifactId>
    			<version>1.0.0-m2</version>
    		</dependency>
    		<dependency>
    			<groupId>com.adobe.blazeds</groupId>
    			<artifactId>blazeds-core</artifactId>
    			<version>3.2.0.3978</version>
    		</dependency>
    		<dependency>
    			<groupId>com.adobe.blazeds</groupId>
    			<artifactId>blazeds-common</artifactId>
    			<version>3.2.0.3978</version>
    		</dependency>
    		<dependency>
    			<groupId>com.adobe.blazeds</groupId>
    			<artifactId>blazeds-remoting</artifactId>
    			<version>3.2.0.3978</version>
    		</dependency>
    Any insight is appreciated.

  • #2
    I suggest you brushup your knowledge about the ContextLoaderListener and DispatcherServlet. Currently you are loading your action-servlet.xml TWICE. First the ContextLoaderListener loads it (due to your configuration) secondly your DispatcherServlet loads it...

    Comment


    • #3
      Yep - that is indeed the problem. Thanks.

      Comment

      Working...
      X