|
From: <jue...@we...> - 2003-11-15 12:45:34
|
Colin,
=20
The problem is that you tried to pass a <list> into a String[] =
constructor. The generic constructor argument matcher did not recognize =
that as compatible, therefore it continued with the next constructor. If =
you explicitly specified an index, the matching was not by type and =
therefore worked.
=20
I've just added a check to match an array argument with a List value, =
and also a unit test that instantiates a parent and child =
ClassPathXmlApplicationContext (without explicit indexes specified).
=20
The exception "2 constructor arguments specified but just constructor =
with 1 argument found" was a bit misleading, as it rather indicates "no =
matching constructor found" (with at least the given number of =
arguments). I've already changed its wording.
=20
So please grab the latest CVS snapshot and happily instantiate =
ClassPathXmlApplicationContexts for whatever reason :-)
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Colin Sampaleanu
Gesendet: Fr 14.11.2003 23:55
An: spr...@li...
Betreff: Re: [Springframework-developer] Type 3 IoC support
There is definitely an issue. When trying to use the two argument
constructor, of which there is only one, I get
; nested exception is:
org.springframework.beans.factory.BeanDefinitionStoreException: 2
constructor arguments specified but just constructor with 1 arguments
found in bean 'packaging-context'
org.springframework.beans.factory.BeanDefinitionStoreException: 2
constructor arguments specified but just constructor with 1 arguments
found in bean 'packaging-context'
at
org.springframework.beans.factory.support.AbstractBeanFactory.autowireCon=
structor(AbstractBeanFactory.java:444)
at
org.springframework.beans.factory.support.AbstractBeanFactory.createBean(=
AbstractBeanFactory.java:352)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getSharedIn=
stance(AbstractBeanFactory.java:274)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs=
tractBeanFactory.java:203)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveRefe=
rence(AbstractBeanFactory.java:717)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveValu=
eIfNecessary(AbstractBeanFactory.java:688)
at
org.springframework.beans.factory.support.AbstractBeanFactory.autowireCon=
structor(AbstractBeanFactory.java:418)
at
org.springframework.beans.factory.support.AbstractBeanFactory.createBean(=
AbstractBeanFactory.java:352)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getSharedIn=
stance(AbstractBeanFactory.java:274)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs=
tractBeanFactory.java:203)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveRefe=
rence(AbstractBeanFactory.java:717)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveValu=
eIfNecessary(AbstractBeanFactory.java:688)
at
org.springframework.beans.factory.support.AbstractBeanFactory.autowireCon=
structor(AbstractBeanFactory.java:418)
at
org.springframework.beans.factory.support.AbstractBeanFactory.createBean(=
AbstractBeanFactory.java:352)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getSharedIn=
stance(AbstractBeanFactory.java:274)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs=
tractBeanFactory.java:203)
at
org.springframework.context.support.AbstractApplicationContext.getBean(Ab=
stractApplicationContext.java:468)
at
org.springframework.context.support.AbstractApplicationContext.preInstant=
iateSingletons(AbstractApplicationContext.java:354)
at
org.springframework.context.support.AbstractApplicationContext.refresh(Ab=
stractApplicationContext.java:240)
However, if I add index=3D"0" and index=3D"1" respectively, to the two
constructor arguments, then it has no problem constructing it. Now my
understanding is that the indexes shouldn't be necessary in this
(non-ambiguous) case.
Again, I'll probably be able to look at this on Mon. or Tues. if nobody
else has by then.
Regards,
Colin
Colin Sampaleanu wrote:
> Juergen,
>
> I think the constructor resolution may not be quite right. The
> following bean entry fails:
> <bean id=3D"data-access-context"
> =20
> =
class=3D"org.springframework.context.support.ClassPathXmlApplicationConte=
xt">
>
> <constructor-arg>
> <list><value>/data-access-applicationContext.xml</value></list>
> </constructor-arg>
> </bean>
> with
> ...
> =20
> org.springframework.beans.factory.UnsatisfiedDependencyException: Bean =
w
> ith name 'data-access-context' has an unsatisfied dependency expressed
> through c
> onstructor argument with index 0 of type [java.lang.String]
>
> Where it should be able to resolve to the constructor which takes an
> array of Strings. Now I will probably look into this myself later, but
> wanted to give you a heads up in case you know offhand what the
> problem is. For the time being, I am in a hurry, and will just feed
> the one string I need to the constructor which takes one string.
>
> As to why I am trying to construct a context inside a context, I am
> doing some interesting coding; we can get into that later when
> everything is working :-)
|