Announcement Announcement Module
Collapse
No announcement yet.
can't Autowire ReloadableResourceBundleMessageSource bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't Autowire ReloadableResourceBundleMessageSource bean

    Hi,
    I have this messageSource bean defined into may ApplicationContext.xml
    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basename" value="classpath:refExceptions" />
    <property name="defaultEncoding" value="UTF-8" />
    </bean>
    I injected my messageSource bean into my @Service class like this:

    @Service
    public class EtxExceptionFactory{
    ...
    @Autowired
    @Qualifier("messageSource")
    private ReloadableResourceBundleMessageSource messageSource;
    ...
    public String getMessage(final String code, Object[] libelleParams) {
    MessageSourceResolvable resolvable = new CustomMessageSourceResolvable(code, libelleParams);
    return messageSource.getMessage(resolvable, Locale.FRANCE);
    }
    }

    When i run the unit tests every thing works fine, but when i deploy my binary file into Jboss, i got this Exception:

    2012-05-01 15:12:57,498 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/Ecotaxe_PPE_Enregistrement_Backend]] (main) StandardWrapper.Throwable
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'etxExceptionFactory': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: private org.springframework.context.support.ReloadableReso urceBundleMessageSource com.total.ecotaxe.ppe.factory.EtxExceptionFactory. messageSource; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No matching bean of type [org.springframework.context.support.ReloadableReso urceBundleMessageSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Aut owired(required=true), @org.springframework.beans.factory.annotation.Qual ifier(value=messageSource)}
    at org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor.postProcessPropert yValues(AutowiredAnnotationBeanPostProcessor.java: 288)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 93)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:290 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 42)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 58)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:339 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:306)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1048)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:950)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4122)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4417)
    at org.jboss.web.tomcat.service.deployers.TomcatDeplo yment.performDeployInternal(TomcatDeployment.java: 321)
    at org.jboss.web.tomcat.service.deployers.TomcatDeplo yment.performDeploy(TomcatDeployment.java:145)
    at org.jboss.web.deployers.AbstractWarDeployment.star t(AbstractWarDeployment.java:461)
    at org.jboss.web.deployers.WebModule.startModule(WebM odule.java:122)
    at org.jboss.web.deployers.WebModule.start(WebModule. java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invok e(ReflectedDispatcher.java:157)
    at org.jboss.mx.server.Invocation.dispatch(Invocation .java:96)
    at org.jboss.mx.server.Invocation.invoke(Invocation.j ava:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ab stractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanSe rverImpl.java:668)
    at org.jboss.system.microcontainer.ServiceProxy.invok e(ServiceProxy.java:206)
    at $Proxy38.start(Unknown Source)
    at org.jboss.system.microcontainer.StartStopLifecycle Action.installAction(StartStopLifecycleAction.java :42)
    at org.jboss.system.microcontainer.StartStopLifecycle Action.installAction(StartStopLifecycleAction.java :37)
    at org.jboss.dependency.plugins.action.SimpleControll erContextAction.simpleInstallAction(SimpleControll erContextAction.java:62)
    at org.jboss.dependency.plugins.action.AccessControll erContextAction.install(AccessControllerContextAct ion.java:71)
    at org.jboss.dependency.plugins.AbstractControllerCon textActions.install(AbstractControllerContextActio ns.java:51)
    at org.jboss.dependency.plugins.AbstractControllerCon text.install(AbstractControllerContext.java:348)
    at org.jboss.system.microcontainer.ServiceControllerC ontext.install(ServiceControllerContext.java:297)
    at org.jboss.dependency.plugins.AbstractController.in stall(AbstractController.java:1652)
    at org.jboss.dependency.plugins.AbstractController.in crementState(AbstractController.java:938)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:988)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:826)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:556)
    at org.jboss.system.ServiceController.doChange(Servic eController.java:688)
    at org.jboss.system.ServiceController.start(ServiceCo ntroller.java:460)
    at org.jboss.system.deployers.ServiceDeployer.start(S erviceDeployer.java:163)
    at org.jboss.system.deployers.ServiceDeployer.deploy( ServiceDeployer.java:99)
    at org.jboss.system.deployers.ServiceDeployer.deploy( ServiceDeployer.java:46)
    at org.jboss.deployers.spi.deployer.helpers.AbstractS impleRealDeployer.internalDeploy(AbstractSimpleRea lDeployer.java:62)
    at org.jboss.deployers.spi.deployer.helpers.AbstractR ealDeployer.deploy(AbstractRealDeployer.java:55)
    at org.jboss.deployers.plugins.deployers.DeployerWrap per.deploy(DeployerWrapper.java:179)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doDeploy(DeployersImpl.java:1454)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doInstallParentFirst(DeployersImpl.java:1172)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doInstallParentFirst(DeployersImpl.java:1193)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doInstallParentFirst(DeployersImpl.java:1225)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.install(DeployersImpl.java:1113)
    at org.jboss.dependency.plugins.AbstractControllerCon text.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.in stall(AbstractController.java:1652)
    at org.jboss.dependency.plugins.AbstractController.in crementState(AbstractController.java:938)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:988)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:826)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:556)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.process(DeployersImpl.java:789)
    at org.jboss.deployers.plugins.main.MainDeployerImpl. process(MainDeployerImpl.java:699)
    ...

    Please .. Any idea why i can't @autowire my "messageSource" bean ??
    Tanks

  • #2
    Please use [ code][/code ] tags when posting code/xml/stacktraces, that way it remains readable.

    See my post in the thread you revived.

    1) Use MessageSource instead of the concrete implementation to inject
    2) If you use component-scanning make sure you aren't scanning components twice

    Comment

    Working...
    X