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

  • MessageBroker already defined from MessageBrokerServlet

    Hi All!

    I've tried to build a flex-BlazeDS-Sring project.

    I have got this error:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '_messageBroker': Invocation of init method failed; nested exception is java.lang.RuntimeException: MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = '_messageBroker'
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    java.security.AccessController.doPrivileged(Native Method)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
    org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:380)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 02)
    org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:316 )
    org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:282)
    org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:126)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:117)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:174)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:875)
    org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:665)
    org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:528)
    org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:81)
    org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:689)
    java.lang.Thread.run(Thread.java:619)


    Config files:


    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>

    <display-name>ads-server</display-name>

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

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    <servlet>
    <servlet-name>ads</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>ads</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
    <welcome-file>main.html</welcome-file>
    </welcome-file-list>

    </web-app>


    ads-servlet.xml

    <?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/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/flex
    http://www.springframework.org/schema/flex/spring-flex-1.0.xsd"
    default-autowire="byName" default-lazy-init="false">



    <!--=================== Flex config ========================-->

    <flex:message-broker>
    <flex:mapping pattern="/messagebroker/*" />
    <flex:message-service
    default-channels="my-amf" />
    </flex:message-broker>

    <!-- Expose the myServiceImpl bean for BlazeDS remoting -->
    <flex:remoting-destination ref="myServiceImpl" />

    </beans>



    services-context.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"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <!--
    Enable annotation-based configuration. companyService and industryService
    (used in the Company Manager sample) are configured using annotations.
    Open CompanyDAO.java and IndustryDAO.java for details.
    -->
    <context:annotation-config />
    <context:component-scan base-package="hu.ads" />


    </beans>


    What could be the error?

    Thanks
    bestwick

  • #2
    That error is generally caused by 1 of two possible scenarios:

    1) You are somehow loading the application context containing the <flex:message-broker> multiple times (search the forums for a more detailed explanation of this)

    2) The app failed to startup the first time, you made some changes and just restarted the app without restarting the server (this was due to some improper resource cleanup after a failure and has been fixed in the upcoming 1.0.1)

    Comment


    • #3
      Thank you for your quick ansver!

      Yes after reading forum posts I know that this error could come when my context loaded more then one.

      But

      I solve my problem so:

      I added to ads-servlet.xml:

      <!-- Controller handler adapter, hogy a Controller interface-t implementalo osztalyok tudjanak requestet kiszolgalni. -->
      <bean class="org.springframework.web.servlet.mvc.SimpleC ontrollerHandlerAdapter"/>

      <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
      <property name="alwaysUseFullPath" value="true" />
      <property name="mappings">
      <props>
      <prop key="/messagebroker/*">_messageBroker</prop>
      </props>
      </property>
      </bean>

      thanks again
      bestwick

      Comment

      Working...
      X