You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jacob Bergöö <ja...@gmail.com> on 2009/09/15 16:10:59 UTC

Nullpointer exception when trying to call our mocked soap service

Hi,
we have a problem when we are trying to implement our first service client
using Apache CFX (version 2.2.3). 

We have generated our code from a wsdl file by using the wsdl2java
functionality and that is working fine. We then tried our code by creating a
main method calling our service-client (in Eclipse) and we are using soapUI
to mock the response. This is all working fine also, but now to the problem.
When we have packed our application and deployed it on our weblogic server
(10.3) then we get this error when the service is called:

java.lang.NullPointerException
        at
com.sun.xml.ws.client.WSServiceDelegate.getPortModel(WSServiceDelegate.java:632)
        at
com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312)
        at
com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:306)
        at javax.xml.ws.Service.getPort(Service.java:92)
        ....

Our java code looks like this:

@Override
	public Statistics getStatistics(final String ip, final int timeout) throws
IllegalArgumentException {
		
		if (ip == null) {
            throw new IllegalArgumentException(
                    "Can not contact webservice with ip address == null.");
        }
		String endpointAddress = "http://" + ip + ":80" + WEBSERICE_PATH;
		final Service service = Service.create(SERVICE_NAME);
        service.addPort(SERVICE_NAME, SOAPBinding.SOAP12HTTP_BINDING,
endpointAddress);
        ServicePortType port = service.getPort(SERVICE_NAME,
ServicePortType.class);
        setClientTimeoutPolicy(port, timeout);
        
        StatisticsResponse bs = port.getStatistics();
        return convert(bs);
	}
	
	/**
	 * Adds HTTP client policy
	 */
	private void setClientTimeoutPolicy(ServicePortType port, int timeout) {
		Client client = ClientProxy.getClient(port);
        HTTPConduit http = (HTTPConduit) client.getConduit();

        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setConnectionTimeout(timeout);
        httpClientPolicy.setReceiveTimeout(timeout);
        
        http.setClient(httpClientPolicy);
	}


we are using java 1.6.0_05-b13 and in our pom.xml we have added the
following dependencies:

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <version>2.1.12</version>
	</dependency>
	<dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.1.12</version>
        </dependency>
		<dependency>
    		<groupId>org.apache.cxf</groupId>
    		<artifactId>cxf-rt-frontend-jaxws</artifactId>
                 <version>2.2.3</version>
    	</dependency>
    	<dependency>
    		<groupId>org.apache.cxf</groupId>
    		<artifactId>cxf-rt-transports-http</artifactId>
                <version>2.2.3</version>
    	</dependency>
    	<dependency>
    		<groupId>org.apache.geronimo.specs</groupId>
    		<artifactId>geronimo-annotation_1.0_spec</artifactId>
                <version>1.1</version>
    	</dependency>

We have tried to searched the forum and also searched on google but we
haven't found anything that can help us to solve our problem.


Thanks in advance,
Jacob
-- 
View this message in context: http://www.nabble.com/Nullpointer-exception-when-trying-to-call-our-mocked-soap-service-tp25454738p25454738.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Nullpointer exception when trying to call our mocked soap service

Posted by Daniel Kulp <dk...@apache.org>.
You are most likely getting an HTML error page back instead of a SOAP message.   
I would turn on logging or something to see what is being returned.   The 
normal reason is the wrong URL being used so the service wasn't found at that 
URL.

Dan



On Wed September 16 2009 8:07:00 am Jacob Bergöö wrote:
> Hi Dan,
> Thanks for the response. We have now sorted out (we hope) the class loading
> problems and when we try to run the application we end up with a new
> exception:
> 
> 
> 20090916 134852 DEBUG statisticsAdapterImpl  - Sending request to
>  Statistics service with endpoint address:
>  http://127.0.0.1:8081/cgi-bin/soap.cgi 2009-sep-16 13:48:53
>  org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
> INFO: No cxf.xml configuration file detected, relying on defaults.
> 2009-sep-16 13:48:55
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
> buildServiceFromClass
> INFO: Creating Service StatisticsService from class
> com.somecompany.ws.ServicePortType
> 2009-sep-16 13:48:57 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> VARNING: Interceptor has thrown exception, unwinding now
> org.apache.cxf.binding.soap.SoapFault: No namespace on "HTML" element.
>         at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessag
> e(ReadHeadersInterceptor.java:96) at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessag
> e(ReadHeadersInterceptor.java:58) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:236) at
>  org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:658) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
> eInternal(HTTPConduit.java:2139) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
> e(HTTPConduit.java:2022) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
> duit.java:1947) at
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
>         at
> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
>         at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte
> rceptor.handleMessage(MessageSenderInterceptor.java:62) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:236) at
>  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472) at
>  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302) at
>  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254) at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123)
>         at $Proxy133.getBandwidthStatistics(Unknown Source)
>         at
>         ...
> 20090916 134857 ERROR SomeServerHandler      - Communication with
>  statistics webservice failed:
> javax.xml.ws.soap.SOAPFaultException: No namespace on "HTML" element.
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:143)
>         at $Proxy133.getBandwidthStatistics(Unknown Source)
>         at
>         ...
> Caused by: org.apache.cxf.binding.soap.SoapFault: No namespace on "HTML"
> element.
>         at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessag
> e(ReadHeadersInterceptor.java:96) at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessag
> e(ReadHeadersInterceptor.java:58) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:236) at
>  org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:658) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
> eInternal(HTTPConduit.java:2139) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
> e(HTTPConduit.java:2022) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
> duit.java:1947) at
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
>         at
> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
>         at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte
> rceptor.handleMessage(MessageSenderInterceptor.java:62) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:236) at
>  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472) at
>  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302) at
>  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254) at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123)
>         ... 36 more
> 
> any idea on what can cause this?
> 
> Thanks in advance,
> Jacob
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Nullpointer exception when trying to call our mocked soap service

Posted by Jacob Bergöö <ja...@gmail.com>.
Hi Dan,
Thanks for the response. We have now sorted out (we hope) the class loading
problems and when we try to run the application we end up with a new
exception:


20090916 134852 DEBUG statisticsAdapterImpl  - Sending request to Statistics
service with endpoint address: http://127.0.0.1:8081/cgi-bin/soap.cgi
2009-sep-16 13:48:53 org.apache.cxf.bus.spring.BusApplicationContext
getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
2009-sep-16 13:48:55
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service StatisticsService from class
com.somecompany.ws.ServicePortType
2009-sep-16 13:48:57 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
VARNING: Interceptor has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: No namespace on "HTML" element.
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:96)
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:58)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:658)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2139)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2022)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1947)
        at
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at
org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
        at
org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123)
        at $Proxy133.getBandwidthStatistics(Unknown Source)
        at 
        ...
20090916 134857 ERROR SomeServerHandler      - Communication with statistics
webservice failed:
javax.xml.ws.soap.SOAPFaultException: No namespace on "HTML" element.
        at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:143)
        at $Proxy133.getBandwidthStatistics(Unknown Source)
        at
        ...
Caused by: org.apache.cxf.binding.soap.SoapFault: No namespace on "HTML"
element.
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:96)
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:58)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:658)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2139)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2022)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1947)
        at
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at
org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
        at
org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123)
        ... 36 more

any idea on what can cause this?

Thanks in advance,
Jacob

-- 
View this message in context: http://www.nabble.com/Nullpointer-exception-when-trying-to-call-our-mocked-soap-service-tp25454738p25471016.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Nullpointer exception when trying to call our mocked soap service

Posted by Daniel Kulp <dk...@apache.org>.
Umm... With that stack trace, you are picking up the Sun reference 
implementation, not CXF.   Double check to make sure CXF is properly packaged 
and deployed.

Dan


On Tue September 15 2009 10:10:59 am Jacob Bergöö wrote:
> Hi,
> we have a problem when we are trying to implement our first service client
> using Apache CFX (version 2.2.3).
> 
> We have generated our code from a wsdl file by using the wsdl2java
> functionality and that is working fine. We then tried our code by creating
>  a main method calling our service-client (in Eclipse) and we are using
>  soapUI to mock the response. This is all working fine also, but now to the
>  problem. When we have packed our application and deployed it on our
>  weblogic server (10.3) then we get this error when the service is called:
> 
> java.lang.NullPointerException
>         at
> com.sun.xml.ws.client.WSServiceDelegate.getPortModel(WSServiceDelegate.java
> :632) at
> com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312)
>         at
> com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:306)
>         at javax.xml.ws.Service.getPort(Service.java:92)
>         ....
> 
> Our java code looks like this:
> 
> @Override
> 	public Statistics getStatistics(final String ip, final int timeout) throws
> IllegalArgumentException {
> 
> 		if (ip == null) {
>             throw new IllegalArgumentException(
>                     "Can not contact webservice with ip address == null.");
>         }
> 		String endpointAddress = "http://" + ip + ":80" + WEBSERICE_PATH;
> 		final Service service = Service.create(SERVICE_NAME);
>         service.addPort(SERVICE_NAME, SOAPBinding.SOAP12HTTP_BINDING,
> endpointAddress);
>         ServicePortType port = service.getPort(SERVICE_NAME,
> ServicePortType.class);
>         setClientTimeoutPolicy(port, timeout);
> 
>         StatisticsResponse bs = port.getStatistics();
>         return convert(bs);
> 	}
> 
> 	/**
> 	 * Adds HTTP client policy
> 	 */
> 	private void setClientTimeoutPolicy(ServicePortType port, int timeout) {
> 		Client client = ClientProxy.getClient(port);
>         HTTPConduit http = (HTTPConduit) client.getConduit();
> 
>         HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>         httpClientPolicy.setConnectionTimeout(timeout);
>         httpClientPolicy.setReceiveTimeout(timeout);
> 
>         http.setClient(httpClientPolicy);
> 	}
> 
> 
> we are using java 1.6.0_05-b13 and in our pom.xml we have added the
> following dependencies:
> 
>         <dependency>
>             <groupId>com.sun.xml.bind</groupId>
>             <artifactId>jaxb-xjc</artifactId>
>             <version>2.1.12</version>
> 	</dependency>
> 	<dependency>
>             <groupId>com.sun.xml.bind</groupId>
>             <artifactId>jaxb-impl</artifactId>
>             <version>2.1.12</version>
>         </dependency>
> 		<dependency>
>     		<groupId>org.apache.cxf</groupId>
>     		<artifactId>cxf-rt-frontend-jaxws</artifactId>
>                  <version>2.2.3</version>
>     	</dependency>
>     	<dependency>
>     		<groupId>org.apache.cxf</groupId>
>     		<artifactId>cxf-rt-transports-http</artifactId>
>                 <version>2.2.3</version>
>     	</dependency>
>     	<dependency>
>     		<groupId>org.apache.geronimo.specs</groupId>
>     		<artifactId>geronimo-annotation_1.0_spec</artifactId>
>                 <version>1.1</version>
>     	</dependency>
> 
> We have tried to searched the forum and also searched on google but we
> haven't found anything that can help us to solve our problem.
> 
> 
> Thanks in advance,
> Jacob
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog