Announcement Announcement Module
Collapse
No announcement yet.
Configure Spring Security with Spring BlazeDS Integration in release 1.0.0 M1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configure Spring Security with Spring BlazeDS Integration in release 1.0.0 M1

    Hi,

    Spring BlazeDS Integration 1.0.0.M1 works great without Spring Security. I would like to configure Spring Security. I see that the SpringSecurity could possible be included in the M2 release of the Spring BlazeDS Integration module.

    If i try to configure the security through the DispatchServlet, I get java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

    Since Spring Security requires the ContextLoaderListener, i configured the ContextLoaderListener and passed on the applicatoinContext files. Since the MessageBrokerFactoryBean is initialized through the listener, it is throwing an exception with message.

    "FlexConfigurationManager requires a non-null ServletConfig - Is it being used outside a WebApplicationContext?"

    Was anybody able to configure the security successfully? I am using Tomcat 5.5.

    Thanks
    Prashanth Sukumaran
    Last edited by itsmeprash; Jan 15th, 2009, 02:03 PM.

  • #2
    Got it working.

    So the issue was when loading/wiring the Flex BlazeDS configuration through the ContextLoaderListener (Servlet 2.4 Tomcat 5.5.x) it complained.

    The DispatchServlet code documentation states that

    "A web application can define any number of DispatcherServlets. Each servlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by {@link org.springframework.web.context.ContextLoaderListe ner},
    if any, will be shared."

    So I created three files

    1) applicationContext-security.xml
    2) applicationContext-services.xml
    3) applicationContext-flex.xml

    I am loading applicationContext-security.xml and applicationContext-services.xml through the ContextLoaderListener, so it will be loaded and available to DispatchServlet.

    Then i will load only the applicationContext-flex.xml through the DispatcherServlet.

    This works great for me.

    Comment


    • #3
      itsmeprash, thank you.

      That worked for me too.

      Comment


      • #4
        Unit testing Spring service layer - BlazeDS

        Prasanth

        Thanks for the post. I have encountered the same exception during unit testing services of my spring - flex app.

        I have resolved this issue using the same approach

        Thanks
        Ramesh

        Comment


        • #5
          Thank you

          Thank you, but I have one doubt.
          I am trying to put two dispatcher servlets in to play, one with FLEX and another with the normal MVC!

          this is my web.xml:
          <display-name></display-name>
          <description></description>

          <!-- -->
          <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/applicationContext-services.xml</param-value>
          </context-param>

          <listener>
          <listener-class>
          org.springframework.web.context.ContextLoaderListe ner
          </listener-class>
          </listener>

          <!-- -->
          <servlet>
          <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
          <servlet-class>
          org.springframework.web.servlet.DispatcherServlet
          </servlet-class>
          <init-param>
          <param-name>context</param-name>
          <param-value>/WEB-INF/applicationContext-flex-servlet.xml</param-value>
          </init-param>
          </servlet>

          <servlet-mapping>
          <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
          <url-pattern>/spring/*</url-pattern>
          </servlet-mapping>

          <!-- -->
          <servlet>
          <servlet-name>applicationContext-mvc</servlet-name>
          <servlet-class>
          org.springframework.web.servlet.DispatcherServlet
          </servlet-class>
          </servlet>

          <servlet-mapping>
          <servlet-name>applicationContext-mvc</servlet-name>
          <url-pattern>*.htm</url-pattern>
          </servlet-mapping>



          <welcome-file-list>
          <welcome-file>index.html</welcome-file>
          <welcome-file>index.htm</welcome-file>
          <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>

          </web-app>
          and this is my flex.xml

          <beans>

          <!-- Maps request paths at /* to the BlazeDS MessageBroker -->
          <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
          <property name="mappings">
          <value>
          /*=mySpringManagedMessageBroker
          </value>
          </property>
          </bean>

          <!-- Dispatches requests mapped to a MessageBroker -->
          <bean class="org.springframework.flex.messaging.servlet. MessageBrokerHandlerAdapter"/>

          <!-- Bootstraps and exposes the BlazeDS MessageBroker -->
          <bean id="mySpringManagedMessageBroker" class="org.springframework.flex.messaging.MessageB rokerFactoryBean" />

          </beans>
          and I have this bean in my applicationContext.xml that I would like to be accessed by MVC and FLEX:

          <bean id="toBe" class="org.springframework.flex.messaging.remoting .FlexRemotingServiceExporter">
          <property name="messageBroker" ref="mySpringManagedMessageBroker"/>
          <property name="service" ref="toBeWW"/>
          </bean>

          <bean id="toBeWW" class="com.yoda.cms.workWith.ToBEWW">
          <constructor-arg ref="SeccaoBI"/>
          </bean>
          it gives this error:

          ERROR -- Context initialization failed
          org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'gaia' defined in ServletContext resource [/WEB-INF/applicationContext-services.xml]: Cannot resolve reference to bean 'mySpringManagedMessageBroker' while setting bean property 'messageBroker'; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'mySpringManagedMessageBroker' is defined

          I understand what error it is, but I would suspect that with all xml would be interpreted like one file xml

          Can you help

          thank you

          Comment


          • #6
            Originally posted by itsmeprash View Post
            So the issue was when loading/wiring the Flex BlazeDS configuration through the ContextLoaderListener (Servlet 2.4 Tomcat 5.5.x) it complained.

            The DispatchServlet code documentation states that

            "A web application can define any number of DispatcherServlets. Each servlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by {@link org.springframework.web.context.ContextLoaderListe ner},
            if any, will be shared."

            So I created three files

            1) applicationContext-security.xml
            2) applicationContext-services.xml
            3) applicationContext-flex.xml

            I am loading applicationContext-security.xml and applicationContext-services.xml through the ContextLoaderListener, so it will be loaded and available to DispatchServlet.

            Then i will load only the applicationContext-flex.xml through the DispatcherServlet.

            This works great for me.
            Can you share your configuration and web.xml files? I am facing the same issue, thanks!

            Comment


            • #7
              web.xml

              Good day

              I have devided the aplication-context.xml in two files:

              1. is the file that contain the configuration for flex
              web-application-config.xml
              2. is the one that contain the configuration for the services
              applicationContext.xml

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

              <display-name>8W MEDIA</display-name>
              <description>8W MEDIA</description>

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

              <listener>
              <listener class>
              org.springframework.web.context.ContextLoaderListe ner
              </listener-class>
              </listener>

              <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/config/web-application-config.xml</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
              </servlet>

              <servlet-mapping>
              <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
              <url-pattern>/spring/*</url-pattern>
              </servlet-mapping>

              <welcome-file-list>
              <welcome-file>index.html</welcome-file>
              <welcome-file>index.htm</welcome-file>
              </welcome-file-list>

              <servlet>
              <description></description>
              <display-name>contextServlet</display-name>
              <servlet-name>contextServlet</servlet-name>
              <servlet-class>serviceBrowser.contextServlet</servlet-class>
              <init-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>/WEB-INF/config/web-application-config.xml</param-value>
              </init-param>
              </servlet>

              <servlet>
              <description></description>
              <display-name>SiteServlet</display-name>
              <servlet-name>SiteServlet</servlet-name>
              <servlet-class>com.xpto.xpto.web.SiteServlet</servlet-class>
              </servlet>

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

              </web-app>
              Hope that it can be helfull
              Vasco

              Comment

              Working...
              X