Announcement Announcement Module
Collapse
No announcement yet.
Using bean from dispatcher-servlet.xml in security.xml Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using bean from dispatcher-servlet.xml in security.xml

    Im wrote my own UserDetailsService. And I want inject my facade bean - which is describe in dispatcher-servlet.xml - to authority-provider in securityContext.xml.

    Can I do this some how?

    This not work but I show what kind of solution Im interesting.
    Code:
        <beans:bean id="customUserDetailsService" class="org.mysite.security.CcUserDetailsService">
            <beans:property name="facade" ref="facade" />
        </beans:bean>
    
        <s:authentication-provider user-service-ref="customUserDetailsService" />
    and the problem is that in this context ( security ) the bean facade is not visible but in dispatcher work fine.

    Output of server
    Code:
    ERROR org.springframework.web.context.ContextLoader  - Context initialization failed
    (...) .BeanCreationException: Error creating bean with name 'customUserDetailsService' defined in ServletContext resource [/WEB-INF/securityContext.xml]: Cannot resolve reference to bean 'facade' while setting bean property 'facade';

  • #2
    Beans in the Spring dispatcher-servlet application context are not normally visible to beans in the parent app context.

    Comment


    • #3
      thanx for replay Luke
      I tried bind spring security and hibernate and my own data base schema with authorities and own user table.
      Maybe you can sugesst something instade of my approach with facade.

      In my dispatcher-servlet.xml I have
      Code:
          <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
             <property name="hibernateProperties">
                  <props>
                      <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                      <prop key="hibernate.connection.datasource">jdbc/nowoczesne_cc</prop>
      (...)
      can I reDeclare something like this in Security context and if this make sens? This will be second bean like this but If there is no other way...

      I found this http://www.codercorp.com/blog/spring...-security.html
      but Im not sure where dataSource bean is declared ? And probably in my case better way is to using hibernate some how but I dont know how and where.
      Please help me.
      Last edited by marcintom; May 21st, 2009, 10:05 AM.

      Comment


      • #4
        the dispatcher-servlet.xml should only contain the web related stuff (viewresolvers, handlers, handlermappings etc.). Everything else should be loaded in the shared context. So simply move your LocalSessioNFactoryBean, your services, your daos to the root context.

        Comment


        • #5
          Yes thx. Now I understand http://forum.springsource.org/showthread.php?t=72275

          Comment

          Working...
          X