PDA

View Full Version : BeanNameUrlHandlerMapping - Error creating bean with name 'defaultHandlerMapping'


TonyB
Jul 18th, 2007, 06:10 AM
Hello,

I am trying to use BeanNameUrlHandlerMapping to map a Url (/assistMe) onto a bean (assistMe), but get the following error message on deployment:

2007-07-18 10:40:08 StandardContext[/assist-gui]Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.UnsatisfiedDepen dencyException:
Error creating bean with name 'defaultHandlerMapping' defined in ServletContext resource [/WEB-INF/httpinvoker-servlet.xml]:
Unsatisfied dependency expressed through bean property 'rootHandler':
There are 20 beans of type [java.lang.Object] available for autowiring by type: [assistAction, swaAction, filterChainProxy, httpSessionContextIntegrationFilter, logoutFilter, authenticationProcessingFilter, securityContextHolderAwareRequestFilter, rememberMeProcessingFilter, anonymousProcessingFilter, exceptionTranslationFilter, filterInvocationInterceptor, rememberMeServices, authenticationManager, daoAuthenticationProvider, userDetailsService, dataSource, loggerListener, agentAdapter, assistMe, /assistMe].
There should have been exactly 1 to be able to autowire property 'rootHandler' of bean 'defaultHandlerMapping'.
Consider using autowiring by name instead.


Spring config looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="autodetect">

<bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUr lHandlerMapping">
<property name="defaultHandler"><value>/assistMe</value></property>
</bean>

<bean name="/assistMe" class="org.springframework.remoting.httpinvoker.HttpInvok erServiceExporter">
<property name="service">
<ref bean="assistMe"/>
</property>
<property name="serviceInterface">
<value>com.mytest.AssistMeClient</value>
</property>
</bean>

<bean id="assistAction"
class="com.mytest.AssistAction"
singleton="false">
<property name="assistMe">
<ref local="assistMe"/>
</property>
</bean>

<bean id="assistMe" class="com.mytest.AssistMe" lazy-init="true">
<property name="agentAdapter">
<ref local="agentAdapter"/>
</property>
<property name="timeoutInSeconds">
<value>30</value>
</property>
</bean>

<bean id="agentAdapter" class="com.mytest.VoxAgentAdapter" lazy-init="true"/>

</beans>


Any hints or tips would be greatly appreciated.

Cheers,

TonyB

Marten Deinum
Jul 18th, 2007, 06:15 AM
Disable autowiring or do autowiring by name. Spring tries to find an Object instance to inject into the property 'rootHandler' all beans are of type 'Object' (ofcourse) so there is more then 1 available for auto injecting whereas Spring expects one.

So either disable autowiring and wire everything up yourself or enable autowiring by name. I would disable autowiring and wire everything up yourself (it also performs better, you will get a better startup-time).

TonyB
Jul 18th, 2007, 09:01 AM
Thanks for the information. Will do.