Announcement Announcement Module
Collapse
No announcement yet.
Autowire by type problem, but I'm not using autowiring. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowire by type problem, but I'm not using autowiring.

    Hello,

    I'm getting an error in my unit test setup. It's telling me:
    Code:
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'test.com.cirqular.cortrac.scheduledmail.HibernateCortracNewsEmailTests' defined in null: Unsatisfied dependency expressed through bean property 'cortracNewsDao': There are 2 beans of type [interface com.cirqular.cortrac.scheduledmail.CortracNewsDao] for autowire by type. There should have been 1 to be able to autowire property 'cortracNewsDao' of bean 'test.com.cirqular.cortrac.scheduledmail.HibernateCortracNewsEmailTests'.
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:800)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:720)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:188)
    	at .....
    The problem is that I'm not using autowiring.

    here is my testing config:

    Code:
    <bean id="testCortracNewsDao" class="test.com.cirqular.cortrac.scheduledmail.HibernateCortracNewsEmailTests">
    		<property name="cortracNewsDao" ref="txCortracNewsDao"/>			
    	</bean>
    and the relavent other code:

    Code:
    <bean id="txCortracNewsDao" parent="txProxyTemplate">
    		<property name="target">
    			<bean id="cortracNewsDao" class="com.cirqular.cortrac.scheduledmail.CortracNewsDaoHibernate">
    				<property name="sessionFactory" ref="sessionFactory"/>		
    				<property name="xslTransformUtil" ref="emailDaileyXsl"/>
    				<property name="subject" value="CorTrac News"/>
    				<property name="to">
    					<list>
    						<value>jroberts[email protected]</value>
    					</list>
    				</property>
    				<property name="from" value="$&#123;mail.fromAddress&#125;"/>
    				<property name="buildingGroupId" value="3"/>
    				<property name="movementRangeHours" value="24"/>
    				<property name="hasAccessToDa" value="true"/>
    				<property name="levelIntervalDays" value="7"/>
    				<property name="points" value="75"/>
    				<property name="incidentRangeHours" value="24"/>
    				<property name="scheduleRangeHours" value="24"/>
    				<property name="maxMinutesLate" value="15"/>
    			</bean>	      
    	    </property>
    	</bean>
    			
    	<!-- same as cortracNewsDao, but only has access to work release -->
    	<bean id="txCortracNewsWrDao" parent="txProxyTemplate">
    		<property name="target">			
    			<bean id="cortracNewsWrDao" class="com.cirqular.cortrac.scheduledmail.CortracNewsDaoHibernate">
    				<property name="sessionFactory" ref="sessionFactory"/>		
    				<property name="xslTransformUtil" ref="emailDaileyXsl"/>
    				<property name="subject" value="CorTrac News"/>
    				<property name="to">
    					<list>
    						<value>[email protected]</value>
    					</list>
    				</property>
    				<property name="from" value="$&#123;mail.fromAddress&#125;"/>
    				<property name="buildingGroupId" value="3"/>
    				<property name="movementRangeHours" value="24"/>
    				<property name="hasAccessToDa" value="false"/>
    				<property name="levelIntervalDays" value="7"/>
    				<property name="points" value="75"/>
    				<property name="incidentRangeHours" value="24"/>
    				<property name="scheduleRangeHours" value="24"/>
    				<property name="maxMinutesLate" value="15"/>
    			</bean>
    		</property>
    	</bean>
    Now I do in fact have two beans of Type: CortracNewsDao (defined above)
    But since am specifying ref="txCortracNewsDao", why does that matter?

    argh

  • #2
    Solved, sorta

    I was able to get it working, by changing my interfaces around. I was extending another interface, once I removed that so it was an interface that only extended one interface the problem went away...

    Comment

    Working...
    X