Announcement Announcement Module
Collapse
No announcement yet.
Help I'm going mad Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help I'm going mad

    Hi,

    In brief:
    I have a bean declared in my spring beans file with some properties set using the setter injection. Some other properties of this bean are marked to be autowired. The problem is the autowired properties are not autowired, and when I set required to true there is no exception thrown.

    A bit more info:
    This was working!!!! I don't know what I have changed to stop this from working, but now all of my beans which are both declared in the spring beans file and with Autowire dependencies are no longer being autowired.

    All beans marked as @Service are being picked up, all beans with @Autowired dependencies that are marked as @Service or @Configurable are being wired correctly - so I can be sure the component scan and annotation-config etc..are working . This problem only occurs when the bean is declared in the beans file, and with @Autowired dependencies.....

    I feel like I am going mad....recently I have updated aspectJ from 1.6.7 to 1.6.9 could this be it? I've not modified my beans file from when it workd to when it did not.....

    Now I'm even doubting if this ever worked....

    Can anybody help????

  • #2
    I think we'd have to see some excerpts of your context and code. I just verified in one application that I have a few examples of beans declared in my context that have @Autowired dependencies in the class. This should work.

    What version of Spring are you using?

    Comment


    • #3
      The version of spring is 3.0.3.RELEASE just updated from 3.0.1.RELEASE - at first I thought it may have been the version change that caused it, but I switched back and it didn't seem to fix it.

      Here is some excerpts from the spring-beans.xml file:

      Code:
      	<context:spring-configured />	
      	
      	<context:annotation-config />
      		
      	<aop:aspectj-autoproxy />
      	
      	<context:component-scan base-package="com.metadatatechnology">
      	</context:component-scan>
      	
      	<context:component-scan base-package="org.sdmx">
      	</context:component-scan>
      
      <bean id="registryMetadataManager" class="com.metadatatechnology.sdmx.mtregistry.manager.impl.RegistryMetadataManagerImpl">
      		<property name="registryName" value="${registry.name}" />
      	</bean>
      And here is the related class
      Code:
      public class RegistryMetadataManagerImpl implements RegistryMetadataManager {
      @Autowired
      private MaintainableDao maintainableDao;
      
      .... 
      }
      Not much to go on but I can't really provide much more information at the moment, I'll have to do some more digging when I'm back in the office - but maybe/hopefully the above information will help.

      Comment


      • #4
        Do you really need to use aspectj? I use the "annotation-config" and "component-scan" elements, but I don't use "spring-configured" or "aspectj-autoproxy".

        Comment


        • #5
          Okay - here is what causes it to stop working. Adding spring security.

          Code:
          <security:http auto-config="true">
            <security:intercept-url pattern="/*" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 
            <security:form-login authentication-success-handler-ref="loginRedirectHandler" authentication-failure-handler-ref="loginRedirectHandler"/>
            <security:logout success-handler-ref="loginRedirectHandler"/>
          </security:http>
          	
          <security:global-method-security pre-post-annotations="enabled"/>
          	
          <beans:bean id="loginRedirectHandler" class="com.metadatatechnology.sdmx.mtregistry.servlet.LoginoutRedirectHandler"/>
          	
          <beans:bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
          
          <beans:property name="userDetailsService" ref="hibernateUserDetailsService"/>
          	</beans:bean>
          	
            <flex:message-broker>
               <flex:remoting-service default-channels="my-amf" />
               <flex:secured  />
            </flex:message-broker>
          	
            <security:authentication-manager>
              <security:authentication-provider user-service-ref="hibernateUserDetailsService" ref="daoAuthenticationProvider"/>
            </security:authentication-manager>
          I was pointing the web application to my spring-beans.xml file and a spring-security.xml file. Subsequently I have merged the spring-security beans into the spring-beans.xml file (just to see if that made any difference - it didn't). So I have isolated the cause of the problem to the above code; without this code autowiring works, with it - it breaks. Not sure why....yet....any ideas?

          Comment


          • #6
            Nailed it to this one line:

            Code:
            <flex:message-broker>
                <flex:remoting-service default-channels="my-amf" />
                <flex:secured  />
            </flex:message-broker>
            This breaks autowiring.....and I have no idea why.....

            Actually even with just the following it beaks:
            Code:
            <flex:message-broker />
            Last edited by Agent96; Feb 10th, 2011, 04:18 AM. Reason: More information

            Comment


            • #7
              Okay - so this is still a problem, adding in <flex:message-broker /> breaks autowiring.

              I have read it can be replaced with:
              Code:
              <beans:bean id="_messageBroker" class="org.springframework.flex.core.MessageBrokerFactoryBean" >
                <beans:property name="servicesConfigPath" value="WEB-INF/flex/services-config.xml" />
              </beans:bean>
              Which doesn't break the autowiring, however I wish to replace the entire section:
              Code:
              <flex:message-broker>
                  <flex:remoting-service default-channels="my-amf" />
                  <flex:secured  />
              </flex:message-broker>
              With the bean alternative, but and not sure what the spring bean way of obtaining the same result is...can anyone help me on this???

              Comment

              Working...
              X