0 Replies Latest reply on Sep 16, 2011 11:49 AM by Sam W

    @Autowired with EJB3 beans

    Sam W Expert

      Hi,

       

      With JBOSS AS7, Spring3, JAXWS service consumer, and EJB3, my web application module can't inject EJB3 bean objects into the CategoryFinderController class.

       

      Here is the exception thrown by JBOSS AS7 during its deployment:

       

       

      01:10:27,519 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "CategoryClient-ear.ear"

      01:10:27,724 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) Starting deployment of "CategoryClient-web.war"

      01:10:27,725 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "CategoryClient-ejb-1.0-SNAPSHOT.jar"

      01:10:28,145 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) added javax.persistence.api dependency to CategoryClient-ear.ear

      01:10:28,146 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) added javax.persistence.api dependency to CategoryClient-ejb-1.0-SNAPSHOT.jar

      01:10:28,146 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) added javax.persistence.api dependency to CategoryClient-web.war

      01:10:28,162 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named CategoryManagerImpl in deployment unit subdeployment "CategoryClient-ejb-1.0-SNAPSHOT.jar" of deployment "CategoryClient-ear.ear" are as follows:

       

       

              java:global/CategoryClient-ear/CategoryClient-ejb-1.0-SNAPSHOT/CategoryManagerImpl!ix.houseware.category.CategoryManager

              java:app/CategoryClient-ejb-1.0-SNAPSHOT/CategoryManagerImpl!ix.houseware.category.CategoryManager

              java:module/CategoryManagerImpl!ix.houseware.category.CategoryManager

              java:global/CategoryClient-ear/CategoryClient-ejb-1.0-SNAPSHOT/CategoryManagerImpl

              java:app/CategoryClient-ejb-1.0-SNAPSHOT/CategoryManagerImpl

              java:module/CategoryManagerImpl

       

       

      01:10:28,426 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-7) Initializing Spring root WebApplicationContext

      01:10:28,727 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-7) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'categoryFinderController' defined in "/content/CategoryClient-ear.ear/CategoryClient-web.war/WEB-INF/classes/ix/houseware/category/controller/CategoryFinderController.class": Unsatisfied dependency expressed through constructor argument with index 0 of type [ix.houseware.category.CategoryManager]: : No matching bean of type [ix.houseware.category.CategoryManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [ix.houseware.category.CategoryManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

              at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [spring-context-3.0.6.RELEASE.jar:]

              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [spring-context-3.0.6.RELEASE.jar:]

              at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) [spring-web-3.0.6.RELEASE.jar:]

              at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) [spring-web-3.0.6.RELEASE.jar:]

              at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.6.RELEASE.jar:]

              at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]

              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]

              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [:1.6.0_03-p4]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [:1.6.0_03-p4]

              at java.lang.Thread.run(Thread.java:619) [:1.6.0_03-p4]

      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [ix.houseware.category.CategoryManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723) [spring-beans-3.0.6.RELEASE.jar:]

              ... 23 more

       

       

      01:10:28,731 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-7) Error listenerStart

      01:10:28,731 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-7) Context [/CategoryClient-web] startup failed due to previous errors

      01:10:28,741 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-7) Closing Spring root WebApplicationContext

      01:10:28,743 INFO  [org.jboss.web] (MSC service thread 1-7) registering web context: /CategoryClient-web

      01:10:28,755 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployed "CategoryClient-ear.ear"

       

       

      I also attached my sample project for reference.

       

      Any suggestion is very appreciated.

       

      Thanks

      Sam