Announcement Announcement Module
Collapse
No announcement yet.
Proper way to configure Spring BlazeDS, MVC, and Security Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Proper way to configure Spring BlazeDS, MVC, and Security

    This question could probably be spread over multiple forums but I decided to start here. I think the big issue I'm up against is how to get Spring MVC and BlazeDS integration running in the same web app. I can get them both working, but as soon as I throw Spring Security into the mix I have to tweak the configurations and I can only get one or the other working.

    The only way I have gotten MVC and Blaze working together is by declaring two Dispatch Servlets, one for MVC, one for BLazeDS:

    HTML Code:
    <context-param>
    	<param-name>contextConfigLocation</param-name>
    	<param-value>
    		classpath:/config/applicationContext.xml
    		classpath:/config/blazeContext.xml
    	</param-value>
    </context-param>
    
    LISTENERS AND FILTER....
    
    <servlet>
    	<servlet-name>mvc-dispatcher</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:config/mvc-dispatcher-servlet.xml</param-value>
    	</init-param>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    	<servlet-name>amf-dispatcher</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:config/amf-dispatcher-servlet.xml</param-value>
    	</init-param>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>mvc-dispatcher</servlet-name>
    	<url-pattern>*.html</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
           <servlet-name>amf-dispatcher</servlet-name>
           <url-pattern>/messagebroker/*</url-pattern>
       </servlet-mapping>
    Is this actually the best/only way to configure these two project on the same app? I would really like to have this run through one dispatcher but have had no luck in that arena. Then I add the security context to the web.xml root context and @secured on my mvc controllers quits working, so I move the mvc configuration file from the servlet to the web.xml root and @secured works in the controllers, but then my amf channel starts throwing 500 errors as it is trying to resolve the "amf" view, however that is probably the secondary problem.

    Any ideas?

    thanks!

  • #2
    Did you had a look at http://static.springsource.org/sprin...l/ch02s04.html ?

    I've smething like :
    web.xml
    Code:
        <servlet-mapping>
            <servlet-name>spring-dispatcher</servlet-name>
            <url-pattern>/flex/*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>spring-dispatcher</servlet-name>
            <url-pattern>/file/*</url-pattern>
        </servlet-mapping>
    spring-dispatcher-servlet.xml
    Code:
     <?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:sec="http://www.springframework.org/schema/security"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
     
    	<description>Spring Web MVC-specific components</description>
     
    	<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="alwaysUseFullPath" value="true" />
    		<property name="mappings">
    			<props>
    				<prop key="/file/*">fileTransfertController</prop>
    				<prop key="/messagebroker/*">_messageBroker</prop>
    			</props>
    		</property>
    	</bean>
     
    	<bean id="controllerHandlerAdapter" class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
     
    </beans>

    Comment

    Working...
    X