|
From: Michael E. M. <mm...@re...> - 2005-09-21 16:24:58
|
In AbstractDependencyInjectionSpringContextTests.setUp(),
I can't make the bean get wired by Spring just like any other Spring bean.
The problem occurs when I mess with setPopulateProtectedVariables(true).
I end up with only one of my three dependencies being populated..
protected final void setUp() throws Exception {
this.applicationContext = getContext(contextKey());
if (isPopulateProtectedVariables()) {
if (this.managedVariableNames == null) {
initManagedVariableNames();
}
populateProtectedVariables();
}
else {
this.applicationContext.getBeanFactory().autowireBeanProperties(
this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE,
isDependencyCheck());
}
try {
onSetUp();
}
catch (Exception ex) {
logger.error("Setup error", ex);
throw ex;
}
}
Thomas R. Corbin wrote:
>On Tuesday, 20 September 2005 10:00 pm, Michael E. Moores wrote:
>
>
>>ok i tried setting the "mpChargeTest" bean autowire property to values
>>"no" and "byName"
>>and it still gets confused by the testDaoX bean- the one that is proxied.
>>
>>
>
> Try calling this in your constructor:
>
> setPopulateProtectedVariables( true );
>
> Then any protected member data that matches the name of a bean will be filled
>in.
>
> protected Whatever mpChargeTest;
>
>
>
>>Michael E. Moores wrote:
>>
>>
>>>I just swapped in AbstractDependencyInjectionSpringContextTests,
>>>and I end up with an error message That I don't understand at all.
>>>Why would spring complain about autowire problems when I'm not using
>>>autowire???
>>>"There are 2 beans of type [interface com.real.test.mpm.dao.ITestDao]
>>>for autowire by type. There should have been 1 to be able to autowi
>>>re property 'testDao' of bean 'com.real.test.mpm.jaxrpc.TestMpCharge2'."
>>>
>>>
>>><bean id="testDaoTarget" class="com.real.test.mpm.dao.TestDao">
>>> <property name="sessionFactory" ref="testSessionFactory"/>
>>> </bean>
>>><bean id="testDaoX"
>>>class="org.springframework.transaction.interceptor.TransactionProxyFactor
>>>yBean">
>>>
>>> <property name="transactionManager"><ref
>>>bean="testTransactionManager"/></property>
>>> <property name="target"><ref local="testDaoTarget"/></property>
>>> <property name="transactionAttributes">
>>> <props>
>>> <prop key="*">PROPAGATION_REQUIRED</prop>
>>> </props>
>>> </property>
>>></bean>
>>><bean name="mpChargeTest" class="com.real.test.mpm.jaxrpc.TestMpCharge2">
>>> <property name="testDao"><ref local="testDaoX"/></property>
>>> <property name="service" ref="micropaymentService"/>
>>> <property name="musicStoreService" ref="testMusicStoreService"/>
>>></bean>
>>>
>>>
>>>Testcase: testMpCharge took 4.631 sec
>>> Caused an ERROR
>>>Error creating bean with name 'com.real.test.mpm.jaxrpc.TestMpCharge2'
>>>defined in null: Unsatisfied dependency expressed through bean
>>>property 't
>>>estDao': There are 2 beans of type [interface
>>>com.real.test.mpm.dao.ITestDao] for autowire by type. There should
>>>have been 1 to be able to autowi
>>>re property 'testDao' of bean 'com.real.test.mpm.jaxrpc.TestMpCharge2'.
>>>org.springframework.beans.factory.UnsatisfiedDependencyException:
>>>Error creating bean with name 'com.real.test.mpm.jaxrpc.TestMpCharge2'
>>>defined
>>>in null: Unsatisfied dependency expressed through bean property
>>>'testDao': There are 2 beans of type [interface
>>>com.real.test.mpm.dao.ITestDao] f
>>>or autowire by type. There should have been 1 to be able to autowire
>>>property 'testDao' of bean 'com.real.test.mpm.jaxrpc.TestMpCharge2'.
>>> at
>>>org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
>>>ory.autowireByType(AbstractAutowireCapableBeanFactory.java:89
>>>
>>>6)
>>> at
>>>org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
>>>ory.populateBean(AbstractAutowireCapableBeanFactory.java:816)
>>>
>>> at
>>>org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
>>>ory.autowireBeanProperties(AbstractAutowireCapableBeanFactory
>>>
>>>.java:200)
>>> at
>>>org.springframework.test.AbstractDependencyInjectionSpringContextTests.se
>>>tUp(AbstractDependencyInjectionSpringContextTests.java:138)
>>>
>>>
>>-------------------------------------------------------
>>SF.Net email is sponsored by:
>>Tame your development challenges with Apache's Geronimo App Server.
>>Download it for free - -and be entered to win a 42" plasma tv or your very
>>own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
>>_______________________________________________
>>Springframework-user mailing list
>>Spr...@li...
>>https://lists.sourceforge.net/lists/listinfo/springframework-user
>>
>>
>
>
>-------------------------------------------------------
>SF.Net email is sponsored by:
>Tame your development challenges with Apache's Geronimo App Server. Download
>it for free - -and be entered to win a 42" plasma tv or your very own
>Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
>_______________________________________________
>Springframework-user mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-user
>
>
>
>
|