You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gautam Saggar <ga...@gmail.com> on 2011/07/14 22:07:04 UTC

CXF Memory Leak with 2.1.5

Hi,

We have been using the CXF 2.1.5 library as WS client from quite some time.
Recently we started observing a memory leak happening on the client side and
on further investigation it zeroed down to few cxf classes. (refer
CXF-InstanceSizes.JPG)

While we were working on digging into the leak we also thought of upgrading
to newer version as we were on an older one.
Hence, we upgraded the client to CXF 2.4 without making any changes to our
code, and memory profilers showed a stable memory graph. (refer
CXFSize-2.4.0.JPG)

Then in a separate attempt, we changed the way we were creating the
client (snippets below) keeping the client version as CXF 2.1.5 and that
also solved the memory leak problem for us.
I would like to ask the group, based on the changes we did in our code,
that

   - Was there any leak associated to creation of "*JaxWsProxyFactoryBean*"
   in 2.1.5 that was fixed in later releases, as without any changes our code
   works well in later releases.
   - Are the changes that we are doing correctly initializing and using CXF
   or is there any other ideal way to use it.


*Ealier Client Code** (Leaks in 2.1.5 but not in later versions)*
                JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ServiceClient.class);
factory.setAddress(webServiceAddress);

ServiceClient serviceClient = null;
try {
serviceClient = (ServiceClient ) factory.create();
Client client = ClientProxy.getClient(serviceClient );
if (client != null){
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
..
                        policy.setConnectionTimeout(connectionTimeOut);
policy.setReceiveTimeout(connectionTimeOut);
conduit.setClient(policy);
}

} catch (Exception ex) {

} catch (Error er) {

}

***Above code is called for every request that is made from the client.*

In the changed code we are calling the above snippet only once to create the
'*ServiceClient*' and then reusing the serviceClient in subsequent calls.
Please let me know if any further details are required to answer my queries.

Thanks in advance.

-- 
Carpe Diem!
Gautam Saggar

Re: CXF Memory Leak with 2.1.5

Posted by Freeman Fang <fr...@gmail.com>.
On 2011-7-15, at 上午4:07, Gautam Saggar wrote:

> Hi,
>
> We have been using the CXF 2.1.5 library as WS client from quite  
> some time.
> Recently we started observing a memory leak happening on the client  
> side and on further investigation it zeroed down to few cxf classes.  
> (refer CXF-InstanceSizes.JPG)
>
> While we were working on digging into the leak we also thought of  
> upgrading to newer version as we were on an older one.
> Hence, we upgraded the client to CXF 2.4 without making any changes  
> to our code, and memory profilers showed a stable memory graph.  
> (refer CXFSize-2.4.0.JPG)
>
> Then in a separate attempt, we changed the way we were creating the  
> client (snippets below) keeping the client version as CXF 2.1.5 and  
> that also solved the memory leak problem for us.
> I would like to ask the group, based on the changes we did in our  
> code, that
> Was there any leak associated to creation of "JaxWsProxyFactoryBean"  
> in 2.1.5 that was fixed in later releases, as without any changes  
> our code works well in later releases.
> Are the changes that we are doing correctly initializing and using  
> CXF or is there any other ideal way to use it.
>
Hi,

Yeah, dozens of memory leak related issues get resolved after 2.1.5,  
so definitely try the latest version if you can.

Create client proxy once and use it later on is ok for most cases, as  
it's thread safe in most cases, you may need take a look at[1], "Are  
JAX-WS client proxies thread safe?" part for more details.

[1]http://cxf.apache.org/faq.html

Freeman
> Ealier Client Code** (Leaks in 2.1.5 but not in later versions)
>                 JaxWsProxyFactoryBean factory = new  
> JaxWsProxyFactoryBean();
> 		factory.setServiceClass(ServiceClient.class);
> 		factory.setAddress(webServiceAddress);
>
> 		ServiceClient serviceClient = null;
> 		try {
> 			serviceClient = (ServiceClient ) factory.create();
> 			Client client = ClientProxy.getClient(serviceClient );
> 			if (client != null){
> 			HTTPConduit conduit = (HTTPConduit) client.getConduit();
> 			HTTPClientPolicy policy = new HTTPClientPolicy();
> 			..
>                          
> policy.setConnectionTimeout(connectionTimeOut);
> 			policy.setReceiveTimeout(connectionTimeOut);
> 			conduit.setClient(policy);
> 			}
>
> 		} catch (Exception ex) {
>
> 		} catch (Error er) {
>
> 		}
>
> **Above code is called for every request that is made from the client.
>
> In the changed code we are calling the above snippet only once to  
> create the 'ServiceClient' and then reusing the serviceClient in  
> subsequent calls.
> Please let me know if any further details are required to answer my  
> queries.
>
> Thanks in advance.
>
> -- 
> Carpe Diem!
> Gautam Saggar

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: Does CXF support Webservice Http binding?

Posted by xuhb <xu...@tongtech.com>.
Thanks Jinglong Wang, I have tried, your suggestion cannot works, there
always a Exception(
Caused by: org.apache.cxf.BusException: No binding factory for namespace
http://schemas.xmlsoap.org/wsdl/http/ registered.
);

I have check the CXF's Http-Binding 's online document, take a look at the
source code of CXF's http-binding also.
It seems the CXF's http-binding do not suppor the WSDL1.1's  HTTP-Binding
specification(xmlns = "http://schemas.xmlsoap.org/wsdl/http/").

Does anyone can confirm that if CXF http-binding support WSDL1.1's
HTTP-Binding or nor?

Thanks any suggestion.

> -----Original-----
> Sender: Jinglong Wang [mailto:nogrief@gmail.com]
> Date: 2011/7/19 10:05
> Receiver: users@cxf.apache.org
> Subject: Re: Does CXF support Webservice Http binding?
> 
> maybe another...
> 
> <jaxws:server name="restws"
> serviceClass="demo.services.IRestPort"
> address="/restws" wsdlLocation="classpath:restful.wsdl"
> bindingId="http://apache.org/cxf/binding/http">
> 
> On Sun, Jul 17, 2011 at 3:54 PM, xuhb <xu...@tongtech.com> wrote:
> 
> > Hi:
> >
> >       Axis2 & .net could publish a PortType with Http-Binding in WSDL.
> > That's to say: when user write a service business logical, the user
could
> > choose to publish the service interface to be a Soap-Binding Webservice
or
> > a
> > Http-Binding Webservice without changed the definition of java /.net
source
> > code
> >
> >
> >
> >       I have checked the online document of CXF HTTP-Binding. But it
seems
> > the cxf 's http  binding contract is defined by  Annotation of java
code,
> > but not WSDL. So I am wondering  if CXF support to publish a JAVA
Interface
> > to be a Http-Binding WebService (the http-binding contract is defined in
> > WSDL , but not in JAVA Code)?
> >
> >
> >
> >
> >
> >       It' s usage may looks like as following:
> >
> >       1) predefined wsdl :
> >
> >       <wsdl>
> >
> >                <wsdl:portType name="hello"/>
> >
> >                <wsdl:binding name="httpBinding">
> >
> >                          <http:binding verb="POST"/>
> >
> >                          .
> >
> >                </wsdl:binding>
> >
> >                <wsdl:service name="httpBindingService">
> >
> >                          <wsdl:port binding="s:httpBinding"
> > name="httpBindingEndpoint"/>
> >
> >                </wsdl:service>
> >
> >       <wsdl>
> >
> >       2) publish the java service with existing wsdl
> >
> >
> >
> >       <jaxws:endpoint  implementor="some.interface.implement"
> >
> > endpoint="s:httpBindingEndpoint"
> >
> > serviceName="s:httpBindingService
> >
> > wsdlLocation="classpath:http-binding-hello.wsdl">
> >
> >       </jaxws:endpoint>
> >
> >
> >
> >
> >
> > Thanks any suggestion
> >
> >
> 
> 
> --
> 命运并不是不可战胜的,平等需要自己去争取,平等不会白白让你取得。想要平等,
> 必须有劳动,有付出,有汗水,有坚定的信念。



Re: Does CXF support Webservice Http binding?

Posted by Jinglong Wang <no...@gmail.com>.
maybe another...

<jaxws:server name="restws"
serviceClass="demo.services.IRestPort"
address="/restws" wsdlLocation="classpath:restful.wsdl"
bindingId="http://apache.org/cxf/binding/http">

On Sun, Jul 17, 2011 at 3:54 PM, xuhb <xu...@tongtech.com> wrote:

> Hi:
>
>       Axis2 & .net could publish a PortType with Http-Binding in WSDL.
> That's to say: when user write a service business logical, the user could
> choose to publish the service interface to be a Soap-Binding Webservice or
> a
> Http-Binding Webservice without changed the definition of java /.net source
> code
>
>
>
>       I have checked the online document of CXF HTTP-Binding. But it seems
> the cxf 's http  binding contract is defined by  Annotation of java code,
> but not WSDL. So I am wondering  if CXF support to publish a JAVA Interface
> to be a Http-Binding WebService (the http-binding contract is defined in
> WSDL , but not in JAVA Code)?
>
>
>
>
>
>       It' s usage may looks like as following:
>
>       1) predefined wsdl :
>
>       <wsdl>
>
>                <wsdl:portType name="hello"/>
>
>                <wsdl:binding name="httpBinding">
>
>                          <http:binding verb="POST"/>
>
>                          .
>
>                </wsdl:binding>
>
>                <wsdl:service name="httpBindingService">
>
>                          <wsdl:port binding="s:httpBinding"
> name="httpBindingEndpoint"/>
>
>                </wsdl:service>
>
>       <wsdl>
>
>       2) publish the java service with existing wsdl
>
>
>
>       <jaxws:endpoint  implementor="some.interface.implement"
>
> endpoint="s:httpBindingEndpoint"
>
> serviceName="s:httpBindingService
>
> wsdlLocation="classpath:http-binding-hello.wsdl">
>
>       </jaxws:endpoint>
>
>
>
>
>
> Thanks any suggestion
>
>


-- 
命运并不是不可战胜的,平等需要自己去争取,平等不会白白让你取得。想要平等,必须有劳动,有付出,有汗水,有坚定的信念。

Re: Does CXF support Webservice Http binding?

Posted by Jinglong Wang <no...@gmail.com>.
maybe...

<jaxws:binding>
  	   </jaxws:binding>



On Sun, Jul 17, 2011 at 3:54 PM, xuhb <xu...@tongtech.com> wrote:

> Hi:
>
>       Axis2 & .net could publish a PortType with Http-Binding in WSDL.
> That's to say: when user write a service business logical, the user could
> choose to publish the service interface to be a Soap-Binding Webservice or
> a
> Http-Binding Webservice without changed the definition of java /.net source
> code
>
>
>
>       I have checked the online document of CXF HTTP-Binding. But it seems
> the cxf 's http  binding contract is defined by  Annotation of java code,
> but not WSDL. So I am wondering  if CXF support to publish a JAVA Interface
> to be a Http-Binding WebService (the http-binding contract is defined in
> WSDL , but not in JAVA Code)?
>
>
>
>
>
>       It' s usage may looks like as following:
>
>       1) predefined wsdl :
>
>       <wsdl>
>
>                <wsdl:portType name="hello"/>
>
>                <wsdl:binding name="httpBinding">
>
>                          <http:binding verb="POST"/>
>
>                          .
>
>                </wsdl:binding>
>
>                <wsdl:service name="httpBindingService">
>
>                          <wsdl:port binding="s:httpBinding"
> name="httpBindingEndpoint"/>
>
>                </wsdl:service>
>
>       <wsdl>
>
>       2) publish the java service with existing wsdl
>
>
>
>       <jaxws:endpoint  implementor="some.interface.implement"
>
> endpoint="s:httpBindingEndpoint"
>
> serviceName="s:httpBindingService
>
> wsdlLocation="classpath:http-binding-hello.wsdl">
>
>       </jaxws:endpoint>
>
>
>
>
>
> Thanks any suggestion
>
>


-- 
命运并不是不可战胜的,平等需要自己去争取,平等不会白白让你取得。想要平等,必须有劳动,有付出,有汗水,有坚定的信念。

Does CXF support Webservice Http binding?

Posted by xuhb <xu...@tongtech.com>.
Hi:

       Axis2 & .net could publish a PortType with Http-Binding in WSDL.
That's to say: when user write a service business logical, the user could
choose to publish the service interface to be a Soap-Binding Webservice or a
Http-Binding Webservice without changed the definition of java /.net source
code

 

       I have checked the online document of CXF HTTP-Binding. But it seems
the cxf 's http  binding contract is defined by  Annotation of java code,
but not WSDL. So I am wondering  if CXF support to publish a JAVA Interface
to be a Http-Binding WebService (the http-binding contract is defined in
WSDL , but not in JAVA Code)?

 

 

       It' s usage may looks like as following:

       1) predefined wsdl :

       <wsdl>

                <wsdl:portType name="hello"/>

                <wsdl:binding name="httpBinding">

                          <http:binding verb="POST"/>

                          .

                </wsdl:binding>

                <wsdl:service name="httpBindingService">

                          <wsdl:port binding="s:httpBinding"
name="httpBindingEndpoint"/>

                </wsdl:service>

       <wsdl>

       2) publish the java service with existing wsdl

 

       <jaxws:endpoint  implementor="some.interface.implement" 

endpoint="s:httpBindingEndpoint"

serviceName="s:httpBindingService 

wsdlLocation="classpath:http-binding-hello.wsdl">

       </jaxws:endpoint>

 

 

Thanks any suggestion