The error message suggests that your problem is that somewhere you say:
@Inject FooInterface fooBean;
and Spring cannot figure out which one you meant ...
Moises
Sent from my iPhone
On Aug 12, 2010, at 5:24 PM, Mikey <mike.key_at_gmail.com> wrote:
> I have a Jersey project integrated with spring that uses multiple context files and merges them in web.xml like follows:
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>
> classpath*:/module1.xml
> classpath*:/module2.xml
> classpath*:/module3.xml
> classpath*:/module4.xml
> </param-value>
> </context-param>
>
> I have 2 beans with different names implementing the same interface in module3 and module4 spring config's. In module2 I have a class that uses one of those two beans.
>
> eg.
>
> In module3:
>
> <bean id="beanFoo" class="com.foo.FooInterface"/>
>
> In module4:
>
> <bean id="beanBar" class="com.foo.FooInterface"/>
>
> In module2:
>
> <bean id="moduleService" class="com.foo.ServiceInterface">
> <property name="fooDependency" ref="beanFoo"/>
> </bean>
>
> In my Jersey resource I inject the moduleService using @Inject:
>
> @Inject
> private ServiceInterface moduleService;
>
> However when I run this configuration I get the following runtime exception:
>
> SEVERE: Exception occurred when intialization
> java.lang.RuntimeException: There are multiple beans configured in spring for the type com.liveensure.dao.admin.ConsumerDao.
> Annotation information was not available, the reason might be because you're not using @Inject. You should use @Inject and specifiy the bean name via Inject("yourBean").
> Available bean names: beanFoo, beanBar
>
> I can't seem to figure out why Jersey is doing any sort of dependency checking and also unable to determine which bean is being used by the moduleService bean.
>
> I am not using component scan in the Jersey spring config. but rather explicitly defining the bean names. However I do let the @Inject introspect the moduleService so I'm guessing this is where my trouble lies, I just can't figure out if/why the explicit definition of moduleService isn't being used when looking to inject the bean. Any help/pointers/forehead smacks are greatly appreciated.
>
> Cheers.
>
> Mike
>
>
>
> --
> MiKey