A robust starter web application to ease Java webapp development.

Home | Tutorials | Demos | Issues

Spring 2.5 Autowire no unique bean error

View: New views
3 Messages — Rating Filter:   Alert me  

Spring 2.5 Autowire no unique bean error

by mschipperheyn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Has anyone tried to use Spring 2.5 yet?

You get this error when you try to use the annotated controller with autowiring.

2008-04-03 17:06:20.818::WARN:  Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadCategoryController': Autowiring of methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void nl.project.webapp.controller.LoadCategoryController.setCountryManager(org.appfuse.service.GenericManager); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.appfuse.service.GenericManager] is defined: expected single matching bean but found 30:

Does anybody know a way around this apart from hard writing the XML. I'm really happy to be rid of XML configs, so I would love to be able to use this feature knowing that if I don't use it now, I'll have to refactor everything later.

I also saw in Jira that an item Upgrade to Spring 2.5.1 has been marked as resolved. If I need to upgrade to resolve this issue, is there a way to use the alpha for Appfuse 2.0.2?

Cheers,

Marc

Re: Spring 2.5 Autowire no unique bean error

by mraible :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adding @Qualifier("countryManager") should solve this issue.

If you have JSR-250's JAR in your classpath (or are using JDK 6), you
can also use @Resource(name="countryManager") instead of the more
verbose @Autowired @Qualifier("countryManager").

Matt

On Fri, Apr 4, 2008 at 2:15 AM, mschipperheyn <m.schipperheyn@...> wrote:

>
>  Hi all,
>
>  Has anyone tried to use Spring 2.5 yet?
>
>  You get this error when you try to use the annotated controller with
>  autowiring.
>
>  2008-04-03 17:06:20.818::WARN:  Nested in
>  org.springframework.beans.factory.BeanCreationException: Error creating bean
>  with name 'loadCategoryController': Autowiring of methods failed; nested
>  exception is org.springframework.beans.factory.BeanCreationException: Could
>  not autowire method: public void
>  nl.project.webapp.controller.LoadCategoryController.setCountryManager(org.appfuse.service.GenericManager);
>  nested exception is
>  org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique
>  bean of type [org.appfuse.service.GenericManager] is defined: expected
>  single matching bean but found 30:
>
>  Does anybody know a way around this apart from hard writing the XML. I'm
>  really happy to be rid of XML configs, so I would love to be able to use
>  this feature knowing that if I don't use it now, I'll have to refactor
>  everything later.
>
>  I also saw in Jira that an item Upgrade to Spring 2.5.1 has been marked as
>  resolved. If I need to upgrade to resolve this issue, is there a way to use
>  the alpha for Appfuse 2.0.2?
>
>  Cheers,
>
>  Marc
>  --
>  View this message in context: http://www.nabble.com/Spring-2.5-Autowire-no-unique-bean-error-tp16488177s2369p16488177.html
>  Sent from the AppFuse - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@...
>  For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Spring 2.5 Autowire no unique bean error

by mschipperheyn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Awesome. Thanks!!!

Marc
mraible wrote:
Adding @Qualifier("countryManager") should solve this issue.

If you have JSR-250's JAR in your classpath (or are using JDK 6), you
can also use @Resource(name="countryManager") instead of the more
verbose @Autowired @Qualifier("countryManager").

Matt

On Fri, Apr 4, 2008 at 2:15 AM, mschipperheyn <m.schipperheyn@gmail.com> wrote:
>
>  Hi all,
>
>  Has anyone tried to use Spring 2.5 yet?
>
>  You get this error when you try to use the annotated controller with
>  autowiring.
>
>  2008-04-03 17:06:20.818::WARN:  Nested in
>  org.springframework.beans.factory.BeanCreationException: Error creating bean
>  with name 'loadCategoryController': Autowiring of methods failed; nested
>  exception is org.springframework.beans.factory.BeanCreationException: Could
>  not autowire method: public void
>  nl.project.webapp.controller.LoadCategoryController.setCountryManager(org.appfuse.service.GenericManager);
>  nested exception is
>  org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique
>  bean of type [org.appfuse.service.GenericManager] is defined: expected
>  single matching bean but found 30:
>
>  Does anybody know a way around this apart from hard writing the XML. I'm
>  really happy to be rid of XML configs, so I would love to be able to use
>  this feature knowing that if I don't use it now, I'll have to refactor
>  everything later.
>
>  I also saw in Jira that an item Upgrade to Spring 2.5.1 has been marked as
>  resolved. If I need to upgrade to resolve this issue, is there a way to use
>  the alpha for Appfuse 2.0.2?
>
>  Cheers,
>
>  Marc
>  --
>  View this message in context: http://www.nabble.com/Spring-2.5-Autowire-no-unique-bean-error-tp16488177s2369p16488177.html
>  Sent from the AppFuse - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@appfuse.dev.java.net
>  For additional commands, e-mail: users-help@appfuse.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@appfuse.dev.java.net
For additional commands, e-mail: users-help@appfuse.dev.java.net