JBossWS-CXF Web Service with Spring calls default constructor
bapats Jun 12, 2013 10:59 AMWe are building a CXF Web Service using jbossws-cxf.xml/Spring approach in EAP 6.1. The jaxws:endpoint implementor bean (web service), is constructed with several dependencies (Spring beans) using constructor injection.
Initially, we ran into JBAS011054: Could not find default constructor. As a result we had to add default constructor to the web service.
Here's what is happening with the web service invocation.
- At EAP startup, during deployment, the web service class is constructed with all the Spring injected dependencies as expected.
- When the web service is invoked, the default constructor for the web service is getting called. It constructs a new web service object with the default constructor, and invokes the web service method on this instance. As a result, none of the dependencies are injected, and the call fails. The call stack when it is calling the default constructor is below.
Why is it constructing new web service objects by calling the default constructor, when the web service has been already constructed with the correct injection during deployment time? This is causing the web service to not function. Is there a configuration parameter I am missing that is causing this behavior?
Call stack when default constructor is getting called:
Daemon Thread [http-/127.0.0.1:8443-1] (Suspended (breakpoint at line 99 in TestService))
TestService$$$view8(TestService).() line: 99
TestService$$$view8.() line: not available
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor.newInstance(Object...) line: 513
Class.newInstance0() line: 355
Class.newInstance() line: 308
ProxyFactory(AbstractClassFactory).newInstance() line: 225
ProxyFactory.newInstance(InvocationHandler) line: 270
ViewService$DefaultViewInstanceFactory.createViewInstance(ComponentView, Map) line: 263
ViewService$View.createInstance(Map) line: 157
ViewService$View.createInstance() line: 153
InvocationHandlerJAXWS(AbstractInvocationHandler).getComponentView() line: 79
InvocationHandlerJAXWS(AbstractInvocationHandler).invoke(Endpoint, Invocation) line: 101
JBossWSInvoker.performInvocation(Exchange, Object, Method, Object[]) line: 149
JBossWSInvoker(AbstractInvoker).invoke(Exchange, Object, Method, List