开发者

How to add a Filter in Spring (with BlazeDS)

I want to add a filter to map a specific path in URL.

My server side used Spring 2.5.x, BlazeDS (servlet) with TomCat server.

So, my web.xml file is composed like that :

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

<filter>
    <filter-name>FacebookOAuthFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>       
</filter>

<filter-mapping>
    <filter-name>FacebookOAuthFilter</filter-name>
    <url-pattern>/fbauth</url-pattern>
</filter-mapping>

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

<!-- Spring MVC Servlet (that will route HTTP requests to BlazeDS) -->
<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-main-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

When I start my TomCat server, an exception is catched :

[BlazeDS][ERROR] [Configuration] MessageBroker failed to start:   Exception: flex.messaging.config.ConfigurationException: MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = '_messageBroker'
at flex.messaging.MessageBroker.registerMessageBroker(MessageBroker.java:1916)

COuld you help me please ?

Thank you very much,

开发者_JAVA技巧Anthony


I believe you are loading the incorrect configuration file here...

<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-main-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

you have alreaded loaded /WEB-INF/spring-main-config.xml in the first few lines of the file

http://www.springbyexample.org/examples/simple-flex-webapp.html


This isn't really a Flex or BlazeDS issue, it's a more basic mis-configuration of Spring.

You're configured two separate Spring app-contexts, both with the same set of bean definitions (/WEB-INF/spring-main-config.xml).

The app-context defined by the <context-param> is the app-context associated with the webapp. The app-context defined by the ` is associated with the servlet.

Since you've given the same beans file to both, it'll instantiate and initialize the same set of beans twice, and the second time seems to be failing because the MessageBroker has already been defined.

You either need to break up your bean definitions into two sets, or just remove the first one, and just use the servlet context.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜