Can't instantiate bean facade
samwun9988 Sep 17, 2011 12:55 AMHi,
With Spring3, EJB3, I created a bean facade to encapsulate other service classes within the same jar package. These EJB facade and service classes are supposed used by the WAR module.
But during deployement of the EAR file, JBOSS AS7 throws the following exceptions:
14:02:36,634 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "CategoryClient-ear.ear"
14:02:42,051 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) Starting deployment of "CategoryClient-web.war"
14:02:42,051 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) Starting deployment of "CategoryClient-ejb-1.0-SNAPSHOT.jar"
14:02:43,005 INFO [org.jboss.as.jpa] (MSC service thread 1-8) added javax.persistence.api dependency to CategoryClient-ear.ear
14:02:43,006 INFO [org.jboss.as.jpa] (MSC service thread 1-6) added javax.persistence.api dependency to CategoryClient-web.war
14:02:43,006 INFO [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api dependency to CategoryClient-ejb-1.0-SNAPSHOT.jar
14:02:43,027 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
14:02:43,006 INFO [org.jboss.as.jpa] (MSC service thread 1-6) added javax.persistence.api dependency to CategoryClient-web.war
14:02:43,006 INFO [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api dependency to CategoryClient-ejb-1.0-SNAPSHOT.jar
14:02:43,027 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
14:02:43,198 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-1) Initializing Spring root WebApplicationContext
14:02:43,505 ERROR [stderr] (MSC service thread 1-1) log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.
14:02:43,505 ERROR [stderr] (MSC service thread 1-1) log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by
14:02:43,505 ERROR [stderr] (MSC service thread 1-1) log4j:ERROR [ModuleClassLoader for Module "deployment.CategoryClient-ear.ear:main" from Service Module Loader] whereas object of
type
14:02:43,506 ERROR [stderr] (MSC service thread 1-1) 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].
14:02:43,506 ERROR [stderr] (MSC service thread 1-1) log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
14:02:43,522 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-1) Exception sending context initialized event to l
istener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cate
goryFinderController' 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 resou
rce 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.fac
tory.BeanCreationException: Error creating bean with name 'categoryManager': Injection of resource dependencies failed; nested exception is org.springframework.beans.BeanInstantiatio
nException: Could not instantiate bean class [ix.houseware.category.service.CategoryWebService_Service]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundErr
or: 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.ja
r:]
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
14:02:43,527 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-1) Error listenerStart
14:02:43,527 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-1) Context [/CategoryClient-web] startup failed due to previous errors
14:02:43,537 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CategoryClient-web]] (MSC service thread 1-1) Closing Spring root WebApplicationContext
14:02:43,539 INFO [org.jboss.web] (MSC service thread 1-1) registering web context: /CategoryClient-web
14:02:43,550 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployed "CategoryClient-ear.ear"
Here is my WEB-INF/mvc-dispatcher-servlet.xml file:
<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>
<bean id="categoryManager" class="ix.houseware.category.CategoryManagerImpl"/>
</beans>
The CategoryWebService_Service class is automatically generated by code from wsdl file using Java2wsdl utility.
Here is the CategoryWebService_Service file:
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.3-b02-
* Generated source version: 2.0
*
*/
@WebServiceClient(name = "CategoryWebService", targetNamespace = "http://service.category.houseware.ix/", wsdlLocation = "http://www.ixsystems.com.au/category-ws-0.0.1-SNAPSHOT/services?wsdl")
public class CategoryWebService_Service
extends Service
{
private final static URL CATEGORYWEBSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(ix.houseware.category.service.CategoryWebService_Service.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = ix.houseware.category.service.CategoryWebService_Service.class.getResource(".");
url = new URL(baseUrl, "http://www.ixsystems.com.au/category-ws-0.0.1-SNAPSHOT/services?wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'http://www.ixsystems.com.au/category-ws-0.0.1-SNAPSHOT/services?wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
CATEGORYWEBSERVICE_WSDL_LOCATION = url;
}
public CategoryWebService_Service(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName); // <== here is Line 41 where JBOSS throws exception
}
public CategoryWebService_Service() {
super(CATEGORYWEBSERVICE_WSDL_LOCATION, new QName("http://service.category.houseware.ix/", "CategoryWebService"));
}
/**
*
* @return
* returns CategoryWebService
*/
@WebEndpoint(name = "CategoryWebServiceImplPort")
public CategoryWebService getCategoryWebServiceImplPort() {
return super.getPort(new QName("http://service.category.houseware.ix/", "CategoryWebServiceImplPort"), CategoryWebService.class);
}
}
What have I missing in the configuration?
Very appreciate for any suggestion.
Thanks
Sam