I am trying to use CXF with Spring in Contract-first style. I wrote my
WSDL file with various restrictions and refinements, generated the Java
classes with wsdl2java and implemented my web service. All worked fine,
however I noticed that the WSDL that is being generated is not my WSDL
but the dynamically built WSDL which is generated from Java (which omits
all my specific restrictions etc. specified in the schema.)
So I have put my WSDL file into /WEB-INF/wsdl/ and modified my endpoint
in the spring configuration as follows:
<jaxws:endpoint
id="greetingServiceEndpoint"
implementor="#greetingService"
wsdlLocation="/WEB-INF/wsdl/TestWSDL.wsdl"
serviceName="GreetingService"
endpointName="GreetingPort"
address="/GreetingService"/>
I have tried various variations of the above too, however none seems to
work. I am always getting the following exception. If I remove the
wsdlLocation then everything works perfectly. How do I get Spring and
CXF to expose my WSDL not their dynamically generated one? Am I doing
something wrong or do I have something missing?
Environment: Tomcat 6.0.18, Spring 2.5.5, Apache CXF 2.1.2
Thanks,
Josef
22-Jan-2009 02:24:51 org.springframework.web.context.ContextLoader
initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'greetingServiceEndpoint': Invocation of init method
failed; nested exception is javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Could not
find definition for service
{http://www.springframework.org/schema/beans}GreetingService.
Caused by: javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Could not
find definition for service
{http://www.springframework.org/schema/beans}GreetingService.
at
org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:267)
at
org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:201)
at
org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:394)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242
)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObjec
t(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g
etSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab
stractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab
stractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.pre
InstantiateSingletons(DefaultListableBeanFactory.java:291)
at
org.springframework.context.support.AbstractApplicationContext.refresh(A
bstractApplicationContext.java:352)
at
org.springframework.web.context.ContextLoader.createWebApplicationContex
t(ContextLoader.java:246)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(
ContextLoader.java:189)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized
(ContextLoaderListener.java:49)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.j
ava:3843)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4342
)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja
va:791)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:
627)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java
:553)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:31
1)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSu
pport.java:117)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException:
Could not find definition for service
{http://www.springframework.org/schema/beans}GreetingService.
at
org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:
114)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildService
FromWSDL(ReflectionServiceFactoryBean.java:309)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeSe
rviceModel(ReflectionServiceFactoryBean.java:403)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(Refle
ctionServiceFactoryBean.java:188)
at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsService
FactoryBean.java:164)
at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(
AbstractWSDLBasedEndpointFactory.java:100)
at
org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:
116)
at
org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea
n.java:168)
at
org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:336)
at
org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:251)
... 43 more
22-Jan-2009 02:24:51 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart