0 Replies Latest reply on Sep 16, 2011 10:41 AM by Sam W

    Could not instantiate bean.

    Sam W Expert

      Hi,

       

      With JBOSS AS71 Snapshot, I created an EAR file which consist of EJB, JAXWS web service consumer, and a WAR file.

      During the deployment process, JBOSS throws the following exception:

       

       

      00:26:58,451 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "category-ws-0.0.1-SNAPSHOT.war"

      00:27:23,478 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) Starting deployment of "CategoryClient-ear.ear"

      00:27:23,647 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) Starting deployment of "CategoryClient-ejb-1.0-SNAPSHOT.jar"

      00:27:23,647 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Starting deployment of "CategoryClient-web.war"

      00:27:24,200 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) added javax.persistence.api dependency to CategoryClient-ear.ear

      00:27:24,201 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api dependency to CategoryClient-ejb-1.0-SNAPSHOT.jar

      00:27:24,201 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) added javax.persistence.api dependency to CategoryClient-web.war

      00:27:24,221 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) 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

       

       

      00:27:24,480 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-8) Initializing Spring root WebApplicationContext

      00:27:24,908 ERROR [stderr] (MSC service thread 1-8) log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.

      00:27:24,909 ERROR [stderr] (MSC service thread 1-8) log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by

      00:27:24,909 ERROR [stderr] (MSC service thread 1-8) log4j:ERROR [ModuleClassLoader for Module "deployment.CategoryClient-ear.ear:main" from Service Module Loader] whereas object of type

      00:27:24,910 ERROR [stderr] (MSC service thread 1-8) log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [ModuleClassLoader for Module "deployment.CategoryClient-ear.ear.CategoryClient-web.war:main" from Service Module Loader].

      00:27:24,910 ERROR [stderr] (MSC service thread 1-8) log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].

      00:27:24,960 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-8) 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]: : Error creating bean with name 'categoryManager': Injection of resource dependencies failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ix.houseware.category.service.CategoryWebService_Service]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/BeansException; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryManager': Injection of resource dependencies failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ix.houseware.category.service.CategoryWebService_Service]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/BeansException

              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.BeanCreationException: Error creating bean with name 'categoryManager': Injection of resource dependencies failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ix.houseware.category.service.CategoryWebService_Service]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/BeansException

              at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:301) [spring-context-3.0.6.RELEASE.jar:]

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

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [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.findAutowireCandidates(DefaultListableBeanFactory.java:848) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790) [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

      Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ix.houseware.category.service.CategoryWebService_Service]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/BeansException

       

              at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$WebServiceRefElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615) [spring-context-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) [spring-beans-3.0.6.RELEASE.jar:]

              at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:298) [spring-context-3.0.6.RELEASE.jar:]

              ... 35 more

      Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/BeansException

              at org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory.getSpringBusFactory(JBossWSBusFactory.java:120)

              at org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory.createBus(JBossWSBusFactory.java:54)

              at org.jboss.wsf.stack.cxf.client.ProviderImpl.setValidThreadDefaultBus(ProviderImpl.java:213)

              at org.jboss.wsf.stack.cxf.client.ProviderImpl.createServiceDelegate(ProviderImpl.java:140)

              at javax.xml.ws.Service.<init>(Service.java:57) [jboss-jaxws-api_2.2_spec-2.0.0.Final.jar:2.0.0.Final]

              at ix.houseware.category.service.CategoryWebService_Service.<init>(CategoryWebService_Service.java:41) [CategoryClient-ejb-1.0-SNAPSHOT.jar:]

              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.6.0_03-p4]

              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [:1.6.0_03-p4]

              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [:1.6.0_03-p4]

              at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [:1.6.0_03-p4]

              at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) [spring-beans-3.0.6.RELEASE.jar:]

              ... 39 more

       

       

      00:27:24,977 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Error listenerStart

      00:27:24,978 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Context [/CategoryClient-web] startup failed due to previous errors

      00:27:24,997 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-8) Closing Spring root WebApplicationContext

      00:27:24,999 INFO  [org.jboss.web] (MSC service thread 1-8) registering web context: /CategoryClient-web

      00:27:25,011 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployed "CategoryClient-ear.ear"

       

       

      Here is my WEB-INF/mvc-dispatcher-servlet.xml file in the WAR module:

       

       

      <beans xmlns="http://www.springframework.org/schema/beans"

              xmlns:context="http://www.springframework.org/schema/context"

              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xsi:schemaLocation="

              http://www.springframework.org/schema/beans    

              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

              http://www.springframework.org/schema/context

              http://www.springframework.org/schema/context/spring-context-3.0.xsd">

       

       

              <context:component-scan base-package="ix.houseware.category.controller" />

       

       

              <bean

                      class="org.springframework.web.servlet.view.InternalResourceViewResolver">

                      <property name="prefix">

                              <value>/WEB-INF/pages/</value>

                      </property>

                      <property name="suffix">

                              <value>.jsp</value>

                      </property>

              </bean>

       

       

              <!-- Services -->

          <bean id="categoryManager" class="ix.houseware.category.CategoryManagerImpl" />

         

       

       

      </beans>

       

      the above CategoryManagerImpl class is in the EJB module. I am trying to instantiate an ejb web service client from the WAR module. Because I think if I put the EJB jar file inside the WAR module, the WAR module should be able to access /use all APIs provided by the EJB jar file. (please correct me if I am wrong).

       

      Now, here is my CategoryManagerImpl.java file in the EJB module:

       

       

      @Stateless

      //@LocalBean

      public class CategoryManagerImpl implements CategoryManager {

      //    @WebServiceRef(wsdlLocation = "META-INF/wsdl/www.ixsystems.com.au/category-ws-0.0.1-SNAPSHOT/services.wsdl")

          @WebServiceRef(wsdlLocation = "http://www.ixsystems.com.au/category-ws-0.0.1-SNAPSHOT/services?wsdl")

          private CategoryWebService_Service service;

         

          private static final Logger logger = Logger.getLogger(CategoryManagerImpl.class);

       

       

          @Override

          public Collection<CategorySubcategories> findAll() {

              List<CategorySubcategories> result = new ArrayList<CategorySubcategories>();

              try { // Call Web Service Operation

                  ix.houseware.category.service.CategoryWebService port = service.getCategoryWebServiceImplPort();

                  result = port.findAll();

                  logger.info("Result = " +result.toString());

                  System.out.println("Result = "+result);

              } catch (Exception ex) {

                  throw new RuntimeException(ex.getMessage());

              }

              return result;

          }

         

          @Override

          public Collection<CategorySubcategories> find(final String name, final String desc) {

              List<CategorySubcategories> result = new ArrayList<CategorySubcategories>();

              try { // Call Web Service Operation

                  ix.houseware.category.service.CategoryWebService port = service.getCategoryWebServiceImplPort();

                  // TODO initialize WS operation arguments here

                  result = port.find(name, desc);

                  logger.info("Result = " +result.toString());

              } catch (Exception ex) {

                  throw new RuntimeException(ex.getMessage());

              }

              return result;

          }

         

      }

       

       

      Can anyone tell me what is wrong wtih this error?

      I jsut want to seperate the EJB service layer from the presentation layer. The WAR file contains all JSP and controllers, validator beans etc...

      Any suggestion would be very appreciated.

       

      Thanks

      Sam