Unable to write client for JAX-WS with Jetty embedded
I've been into this for days: I had a WS initially tested with the JDK deployment (SimpleHttpServerJaxWsServiceExporter). At this point the server and clients worked.
The target environment is not JDK, so I switched to deploying to an embedded Jetty. I used this example for guiding my configuration. I ended up with the following Jetty configuration:
Code:
<bean id="jettyServer" class="org.mortbay.jetty.Server"
init-method="start" destroy-method="stop">
<property name="connectors">
<list>
<bean id="Connector"
class="org.mortbay.jetty.nio.SelectChannelConnector"
p:port="8090" />
</list>
</property>
<property name="handlers">
<list>
<bean class="org.mortbay.jetty.servlet.Context">
<property name="sessionHandler">
<bean class="org.mortbay.jetty.servlet.SessionHandler" />
</property>
<property name="servletHandler">
<bean class="org.mortbay.jetty.servlet.ServletHandler">
<property name="servlets">
<list>
<bean class="org.mortbay.jetty.servlet.ServletHolder"
p:name="spring-ws">
<property name="servlet">
<bean class="org.springframework.ws.transport.http.MessageDispatcherServlet" />
</property>
<property name="initParameters">
<map>
<entry key="contextConfigLocation" value="classpath:/jax-ws-embedded-context.xml" />
</map>
</property>
</bean>
</list>
</property>
<property name="servletMappings">
<list>
<bean class="org.mortbay.jetty.servlet.ServletMapping"
p:servletName="spring-ws"
p:pathSpec="/*" />
</list>
</property>
</bean>
</property>
</bean>
<bean class="org.mortbay.jetty.handler.DefaultHandler" />
<bean class="org.mortbay.jetty.handler.RequestLogHandler" />
</list>
</property>
</bean>
The referred jax-ws-embedded-context.xml is here too:
Code:
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<description>An endpoint mapping strategy that looks for @Endpoint and @PayloadRoot annotations.</description>
</bean>
<bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
<description>Enables the MessageDispatchServlet to invoke methods requiring OXM marshalling.</description>
<constructor-arg ref="marshaller"/>
</bean>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"
p:contextPath="br.com.cflex.integration.doc.message" />
<bean id="MPRequestHandler" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"
p:portTypeName="MPRequestHandler"
p:locationUri="/MPRequestHandler/"
p:createSoap12Binding="true">
<property name="schemaCollection">
<bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection"
p:inline="true">
<property name="xsds">
<list>
<value>classpath:/wsdl/MPRequestHandler_schema1.xsd</value>
<value>classpath:/xsd/Acknowledge.xsd</value>
<value>classpath:/xsd/CommonData.xsd</value>
<value>classpath:/xsd/Messages.xsd</value>
</list>
</property>
</bean>
</property>
</bean>
My service seems to be deployed correctly as I can access the WSDL (with XSDs inlined) at http://localhost:8090/MPRequestHandler.wsdl.
But I cannot write a working client configuration. Here is my latest attempt:
Code:
<bean id="mpRequestHandlerClient"
class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="br.com.cflex.integration.doc.service.MPRequestHandler" />
<property name="wsdlDocumentUrl" value="http://localhost:8090/MPRequestHandler.wsdl" />
<property name="namespaceUri" value="http://www.cflex.com.br/doc/service" />
<property name="serviceName" value="MPRequestHandler" />
<property name="endpointAddress" value="http://localhost:8090/MPRequestHandler" />
</bean>
When I start this client configuration, I get the following exception:
Code:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mpRequestHandlerClient' defined in class path resource [auv-client-context.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
...
Caused by: java.lang.NullPointerException
at com.sun.xml.internal.ws.model.wsdl.WSDLOperationImpl.freez(Unknown Source)
at com.sun.xml.internal.ws.model.wsdl.WSDLPortTypeImpl.freeze(Unknown Source)
at com.sun.xml.internal.ws.model.wsdl.WSDLBoundPortTypeImpl.freeze(Unknown Source)
...
This NPE says absolutely nothing to me, so does anyone has got a clue about what is wrong?