You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by nereuschen <ne...@gmail.com> on 2012/10/11 17:25:36 UTC

HTTPConduit throw NullPointerException when invoking close()

hi,all:

     i use a  Client  to invoke .net Web Services,but failed. The CXF
version is 2.6.2;jdk1.6.0_20

    My code like this:

        Client client = ClientProxy.getClient(port);
        HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setConnectionTimeout(5000);
        httpClientPolicy.setAllowChunking(false);
        httpClientPolicy.setReceiveTimeout(20000);
        httpConduit.setClient(httpClientPolicy);

        client.invoke("AddTestMethod  ",xxxx,xxxx);

       but *sometimes *the invoke throw an NullPointerException;the log is:

[2012-10-10 11:24:12  WARN
phase.PhaseInterceptorChain:org.apache.cxf.common.logging.LogUtils.doLog(LogUtils.java:405)]
Interceptor for
{http://www.xxxx.com.cn/}TestInterface#{http://www.xxxx.com.cn/}AddTestMethod 
has thrown exception, unwinding now
java.lang.NullPointerException: NullPointerException invoking
http://www.xxxx.com.cn/TestInterface.asmx: null
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1467)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1457)
        at
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
        at
org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:660)
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:340)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)

I view the HTTPConduit source code

HTTPConduit.java 's close method is :

 public void close() throws IOException {
            try {
                if (buffer != null && buffer.size() > 0) {
                    thresholdNotReached();
                    LoadingByteArrayOutputStream tmp = buffer;
                    buffer = null;
                    super.write(tmp.getRawBytes(), 0, tmp.size());
                }
                if (!written) {
                    handleHeadersTrustCaching();
                }
                if (!cachingForRetransmission) {
                    super.close();
                } else if (cachedStream != null) {
                    super.flush();
                    cachedStream.getOut().close();
                    cachedStream.closeFlowthroughStream();
                }

                try {
                    handleResponse();
                } finally {
                    if (cachingForRetransmission && cachedStream != null) {
                        cachedStream.close();
                    }
                }
            } catch (HttpRetryException e) {
                handleHttpRetryException(e, connection);
            } catch (IOException e) {
                String url = connection.getURL().toString();
                String origMessage = e.getMessage();
                if (origMessage != null && origMessage.contains(url)) {
                    throw e;
                }
                throw mapException(e.getClass().getSimpleName() 
                                   + " invoking " + connection.getURL() + ":
"
                                   + e.getMessage(), e,
                                   IOException.class);
           * } catch (RuntimeException e) {
                throw mapException(e.getClass().getSimpleName() 
                                   + " invoking " + connection.getURL() + ":
"
                                   + e.getMessage(), e,
                                   RuntimeException.class);
            }

*

and the client java code is deployed under tomcat6,the jars i used is:


 activation-1.1.1.jar
 activeio-core-3.1.2.jar
 activemq-core-5.4.1.jar
 antlr-2.7.6.jar
 aopalliance-1.0.jar
 apache-mime4j-0.6.jar
 asm-3.3.1.jar
 aspectjweaver-1.6.10.jar
 audit-core-1.2.4.jar
 authclient-1.0.jar
 axis-1.4.jar
 bcprov-jdk16-140.jar
 bsh-2.0b4.jar
 c3p0-0.9.1.2.jar
 cglib-nodep-2.2.2.jar
 comments-client-1.2.3.jar
 commons-chain-1.1.jar
 commons-codec-1.5.jar
 commons-collections-3.2.1.jar
 commons-dbcp-1.4.jar
 commons-digester-2.1.jar
 commons-discovery-0.2.jar
 commons-fileupload-1.2.2.jar
 commons-io-2.3.jar
 commons-jxpath-1.3.jar
 commons-lang-2.5.jar
 commons-lang3-3.0.1.jar
 commons-net-2.0.jar
 commons-pool-1.5.4.jar
 commons-validator-1.3.1.jar
 concurrentlinkedhashmap-lru-1.2.jar
 cxf-api-2.6.2.jar
 cxf-rt-bindings-soap-2.6.2.jar
 cxf-rt-bindings-xml-2.6.2.jar
 cxf-rt-core-2.6.2.jar
 cxf-rt-databinding-jaxb-2.6.2.jar
 cxf-rt-frontend-jaxws-2.6.2.jar
 cxf-rt-frontend-simple-2.6.2.jar
 cxf-rt-transports-http-2.6.2.jar
 cxf-rt-ws-addr-2.6.2.jar
 cxf-rt-ws-policy-2.6.2.jar
 dom4j-1.6.1.jar
 dubbo-2.3.3.jar
 ejb3-persistence-1.0.2.GA.jar
 fastjson-1.1.6.jar
 fp-api-1.0.0.jar
 geronimo-j2ee-management_1.1_spec-1.0.1.jar
 geronimo-jms_1.1_spec-1.1.1.jar
 gson-2.2.2.jar
 guava-12.0.1.jar
 hibernate-annotations-3.4.0.GA.jar
 hibernate-c3p0-3.3.1.GA.jar
 hibernate-commons-annotations-3.1.0.GA.jar
 hibernate-core-3.3.1.GA.jar
 hibernate-validator-4.2.0.Final.jar
 httpclient-4.1.jar
 httpcore-4.1.jar
 httpmime-4.1-alpha2.jar
 icu4j-4.0.1.jar
 jackson-core-asl-1.9.6.jar
 jackson-mapper-asl-1.9.6.jar
 jai-codec-1.1.3.jar
 jai-core-1.1.3.jar
 jasypt-1.6.jar
 javassist-3.4.GA.jar
 jaxb-impl-2.1.13.jar
 jaxrpc-api-1.1.jar
 jbpm-api-4.4.jar
 jbpm-bpmn-4.4.jar
 jbpm-jpdl-4.4.jar
 jbpm-log-4.4.jar
 jbpm-pvm-4.4.jar
 jcl-over-slf4j-1.6.6.jar
 jdom-1.1.jar
 jline-0.9.94.jar
 joda-time-2.1.jar
 jsr305-1.3.9.jar
 jstl-1.2.jar
 jta-1.1.jar
 juel-engine-2.1.0.jar
 juel-impl-2.2.1.jar
 jul-to-slf4j-1.6.6.jar
 junit-3.8.2.jar
 jxl-2.6.12.jar
 kahadb-5.4.1.jar
 livetribe-jsr223-2.0.5.jar
 log4j-1.2.17.jar
 mail-1.4.1.jar
 memcached-2.3.1.jar
 mybatis-3.0.6.jar
 mybatis-spring-1.0.2.jar
 mysql-connector-java-5.1.13.jar
 neethi-3.0.2.jar
 netty-3.4.1.Final.jar
 org.osgi.core-4.1.0.jar
 oro-2.0.8.jar
 poi-3.8.jar
 poi-ooxml-3.8.jar
 poi-ooxml-schemas-3.8.jar
 postgresql-9.1-901-1.jdbc4.jar
 protobuf-java-2.4.0a.jar
 quartz-1.8.5.jar
 saaj-1.4.2.jar
 slf4j-api-1.6.4.jar
 slf4j-log4j12-1.6.4.jar
 spring-aop-3.0.6.RELEASE.jar
 spring-asm-3.0.6.RELEASE.jar
 spring-aspects-3.0.6.RELEASE.jar
 spring-beans-3.0.6.RELEASE.jar
 spring-context-3.0.6.RELEASE.jar
 spring-context-support-3.0.6.RELEASE.jar
 spring-core-3.0.6.RELEASE.jar
 spring-expression-3.0.6.RELEASE.jar
 spring-instrument-3.0.6.RELEASE.jar
 spring-jdbc-3.0.6.RELEASE.jar
 spring-jms-3.0.6.RELEASE.jar
 spring-orm-3.0.6.RELEASE.jar
 spring-oxm-3.0.6.RELEASE.jar
 spring-tx-3.0.6.RELEASE.jar
 spring-web-3.0.6.RELEASE.jar
 spring-webmvc-3.0.6.RELEASE.jar
 spring-webmvc-portlet-3.0.6.RELEASE.jar
 sslext-1.2-0.jar
 stax2-api-3.1.1.jar
 struts-core-1.3.8.jar
 struts-taglib-1.3.8.jar
 struts-tiles-1.3.8.jar
 tomcat-dbcp-7.0.29.jar
 validation-api-1.0.0.GA.jar
 velocity-1.6.4.jar
 velocity-tools-2.0.jar
 woodstox-core-asl-4.1.4.jar
 wsdl4j-1.6.2.jar
 xml-apis-1.0.b2.jar
 xmlbeans-2.3.0.jar
 xml-resolver-1.2.jar
 xmlschema-core-2.0.3.jar
 xpp3_min-1.1.4c.jar
 xstream-1.3.1.jar
 zookeeper-3.4.3.jar




--
View this message in context: http://cxf.547215.n5.nabble.com/HTTPConduit-throw-NullPointerException-when-invoking-close-tp5716402.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: HTTPConduit throw NullPointerException when invoking close()

Posted by nereuschen <ne...@gmail.com>.
It is not about receive time out.

becasuse   i found that  the NullPointerException occurs after invoking the
web services 1 seconds in client side ,but the server side  response the
request about 4 seconds later

The JDK version cannot be upgraded,Because this is the online system.


Today  i update the cxf from 2.6.2 to 2.7.1 ,but cannot slove the problem.




--
View this message in context: http://cxf.547215.n5.nabble.com/HTTPConduit-throw-NullPointerException-when-invoking-close-tp5716402p5716504.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: HTTPConduit throw NullPointerException when invoking close()

Posted by Willem jiang <wi...@gmail.com>.
First, can you set the ReceiveTimeout a bit longer, the default value is 60000 which means 60 second.
> httpClientPolicy.setReceiveTimeout(20000);


If could be more reasonable to let the client wait for response with a bit longer time.
Second, can you consider to upgrade the JDK version to the latest one? 



-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang




On Thursday, October 11, 2012 at 11:25 PM, nereuschen wrote:

> hi,all:
> 
> i use a Client to invoke .net Web Services,but failed. The CXF
> version is 2.6.2;jdk1.6.0_20
> 
> My code like this:
> 
> Client client = ClientProxy.getClient(port);
> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
> httpClientPolicy.setConnectionTimeout(5000);
> httpClientPolicy.setAllowChunking(false);
> httpClientPolicy.setReceiveTimeout(20000);
> httpConduit.setClient(httpClientPolicy);
> 
> client.invoke("AddTestMethod ",xxxx,xxxx);
> 
> but *sometimes *the invoke throw an NullPointerException;the log is:
> 
> [2012-10-10 11:24:12 WARN
> phase.PhaseInterceptorChain:org.apache.cxf.common.logging.LogUtils.doLog(LogUtils.java:405)]
> Interceptor for
> {http://www.xxxx.com.cn/}TestInterface#{http://www.xxxx.com.cn/}AddTestMethod 
> has thrown exception, unwinding now
> java.lang.NullPointerException: NullPointerException invoking
> http://www.xxxx.com.cn/TestInterface.asmx: null
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1467)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1457)
> at
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
> at
> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:660)
> at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
> at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:340)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
> 
> I view the HTTPConduit source code
> 
> HTTPConduit.java 's close method is :
> 
> public void close() throws IOException {
> try {
> if (buffer != null && buffer.size() > 0) {
> thresholdNotReached();
> LoadingByteArrayOutputStream tmp = buffer;
> buffer = null;
> super.write(tmp.getRawBytes(), 0, tmp.size());
> }
> if (!written) {
> handleHeadersTrustCaching();
> }
> if (!cachingForRetransmission) {
> super.close();
> } else if (cachedStream != null) {
> super.flush();
> cachedStream.getOut().close();
> cachedStream.closeFlowthroughStream();
> }
> 
> try {
> handleResponse();
> } finally {
> if (cachingForRetransmission && cachedStream != null) {
> cachedStream.close();
> }
> }
> } catch (HttpRetryException e) {
> handleHttpRetryException(e, connection);
> } catch (IOException e) {
> String url = connection.getURL().toString();
> String origMessage = e.getMessage();
> if (origMessage != null && origMessage.contains(url)) {
> throw e;
> }
> throw mapException(e.getClass().getSimpleName() 
> + " invoking " + connection.getURL() + ":
> "
> + e.getMessage(), e,
> IOException.class);
> * } catch (RuntimeException e) {
> throw mapException(e.getClass().getSimpleName() 
> + " invoking " + connection.getURL() + ":
> "
> + e.getMessage(), e,
> RuntimeException.class);
> }
> 
> *
> 
> and the client java code is deployed under tomcat6,the jars i used is:
> 
> 
> activation-1.1.1.jar
> activeio-core-3.1.2.jar
> activemq-core-5.4.1.jar
> antlr-2.7.6.jar
> aopalliance-1.0.jar
> apache-mime4j-0.6.jar
> asm-3.3.1.jar
> aspectjweaver-1.6.10.jar
> audit-core-1.2.4.jar
> authclient-1.0.jar
> axis-1.4.jar
> bcprov-jdk16-140.jar
> bsh-2.0b4.jar
> c3p0-0.9.1.2.jar
> cglib-nodep-2.2.2.jar
> comments-client-1.2.3.jar
> commons-chain-1.1.jar
> commons-codec-1.5.jar
> commons-collections-3.2.1.jar
> commons-dbcp-1.4.jar
> commons-digester-2.1.jar
> commons-discovery-0.2.jar
> commons-fileupload-1.2.2.jar
> commons-io-2.3.jar
> commons-jxpath-1.3.jar
> commons-lang-2.5.jar
> commons-lang3-3.0.1.jar
> commons-net-2.0.jar
> commons-pool-1.5.4.jar
> commons-validator-1.3.1.jar
> concurrentlinkedhashmap-lru-1.2.jar
> cxf-api-2.6.2.jar
> cxf-rt-bindings-soap-2.6.2.jar
> cxf-rt-bindings-xml-2.6.2.jar
> cxf-rt-core-2.6.2.jar
> cxf-rt-databinding-jaxb-2.6.2.jar
> cxf-rt-frontend-jaxws-2.6.2.jar
> cxf-rt-frontend-simple-2.6.2.jar
> cxf-rt-transports-http-2.6.2.jar
> cxf-rt-ws-addr-2.6.2.jar
> cxf-rt-ws-policy-2.6.2.jar
> dom4j-1.6.1.jar
> dubbo-2.3.3.jar
> ejb3-persistence-1.0.2.GA.jar
> fastjson-1.1.6.jar
> fp-api-1.0.0.jar
> geronimo-j2ee-management_1.1_spec-1.0.1.jar
> geronimo-jms_1.1_spec-1.1.1.jar
> gson-2.2.2.jar
> guava-12.0.1.jar
> hibernate-annotations-3.4.0.GA.jar
> hibernate-c3p0-3.3.1.GA.jar
> hibernate-commons-annotations-3.1.0.GA.jar
> hibernate-core-3.3.1.GA.jar
> hibernate-validator-4.2.0.Final.jar
> httpclient-4.1.jar
> httpcore-4.1.jar
> httpmime-4.1-alpha2.jar
> icu4j-4.0.1.jar
> jackson-core-asl-1.9.6.jar
> jackson-mapper-asl-1.9.6.jar
> jai-codec-1.1.3.jar
> jai-core-1.1.3.jar
> jasypt-1.6.jar
> javassist-3.4.GA.jar
> jaxb-impl-2.1.13.jar
> jaxrpc-api-1.1.jar
> jbpm-api-4.4.jar
> jbpm-bpmn-4.4.jar
> jbpm-jpdl-4.4.jar
> jbpm-log-4.4.jar
> jbpm-pvm-4.4.jar
> jcl-over-slf4j-1.6.6.jar
> jdom-1.1.jar
> jline-0.9.94.jar
> joda-time-2.1.jar
> jsr305-1.3.9.jar
> jstl-1.2.jar
> jta-1.1.jar
> juel-engine-2.1.0.jar
> juel-impl-2.2.1.jar
> jul-to-slf4j-1.6.6.jar
> junit-3.8.2.jar
> jxl-2.6.12.jar
> kahadb-5.4.1.jar
> livetribe-jsr223-2.0.5.jar
> log4j-1.2.17.jar
> mail-1.4.1.jar
> memcached-2.3.1.jar
> mybatis-3.0.6.jar
> mybatis-spring-1.0.2.jar
> mysql-connector-java-5.1.13.jar
> neethi-3.0.2.jar
> netty-3.4.1.Final.jar
> org.osgi.core-4.1.0.jar
> oro-2.0.8.jar
> poi-3.8.jar
> poi-ooxml-3.8.jar
> poi-ooxml-schemas-3.8.jar
> postgresql-9.1-901-1.jdbc4.jar
> protobuf-java-2.4.0a.jar
> quartz-1.8.5.jar
> saaj-1.4.2.jar
> slf4j-api-1.6.4.jar
> slf4j-log4j12-1.6.4.jar
> spring-aop-3.0.6.RELEASE.jar
> spring-asm-3.0.6.RELEASE.jar
> spring-aspects-3.0.6.RELEASE.jar
> spring-beans-3.0.6.RELEASE.jar
> spring-context-3.0.6.RELEASE.jar
> spring-context-support-3.0.6.RELEASE.jar
> spring-core-3.0.6.RELEASE.jar
> spring-expression-3.0.6.RELEASE.jar
> spring-instrument-3.0.6.RELEASE.jar
> spring-jdbc-3.0.6.RELEASE.jar
> spring-jms-3.0.6.RELEASE.jar
> spring-orm-3.0.6.RELEASE.jar
> spring-oxm-3.0.6.RELEASE.jar
> spring-tx-3.0.6.RELEASE.jar
> spring-web-3.0.6.RELEASE.jar
> spring-webmvc-3.0.6.RELEASE.jar
> spring-webmvc-portlet-3.0.6.RELEASE.jar
> sslext-1.2-0.jar
> stax2-api-3.1.1.jar
> struts-core-1.3.8.jar
> struts-taglib-1.3.8.jar
> struts-tiles-1.3.8.jar
> tomcat-dbcp-7.0.29.jar
> validation-api-1.0.0.GA.jar
> velocity-1.6.4.jar
> velocity-tools-2.0.jar
> woodstox-core-asl-4.1.4.jar
> wsdl4j-1.6.2.jar
> xml-apis-1.0.b2.jar
> xmlbeans-2.3.0.jar
> xml-resolver-1.2.jar
> xmlschema-core-2.0.3.jar
> xpp3_min-1.1.4c.jar
> xstream-1.3.1.jar
> zookeeper-3.4.3.jar
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/HTTPConduit-throw-NullPointerException-when-invoking-close-tp5716402.html
> Sent from the cxf-user mailing list archive at Nabble.com (http://Nabble.com).




Re: HTTPConduit throw NullPointerException when invoking close()

Posted by nereuschen <ne...@gmail.com>.
The jars used by my app  is Version conflicts?

or  cxf 's jar is conflicts with my jars?





--
View this message in context: http://cxf.547215.n5.nabble.com/HTTPConduit-throw-NullPointerException-when-invoking-close-tp5716402p5716403.html
Sent from the cxf-user mailing list archive at Nabble.com.