Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Memory leaks in Java and spring using JaxWsProxyFactoryBean

I have an application in Java that uses CXF to make calls to a web service. The code for the initiator looks like

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.tempuri.IAPIService;

import javax.inject.Inject;

/**
 * Created by flavius on 23/09/14.
 */
@Component()
public class VsJaxWsProxyFactory {

  @Inject
  private Environment env;

  private JaxWsProxyFactoryBean factoryBean = null;

  public Object create() {
    if (factoryBean == null) {

      factoryBean = new JaxWsProxyFactoryBean();
      factoryBean.setServiceClass(IAPIService.class);
      factoryBean.setAddress(env.getProperty("api.wsdl"));
    }
    return factoryBean.create();
  }
}

The application runs fine, but after a while the box starts to consume too much memory and the application starts running slow. When we tried to do a memory analysis we found the following Memory Analysis

It seems that the CXF is somehow creating a new Service configuration object on each call, and is not being released. I can't find much information on org.apache.cxf.jaxws.support.JaxWsServiceConfiguration class and not sure if this is a configuration issue or some internal bug in some library.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Already answered here: Apache CXF not releasing clients

Basically .create() method on the same JaxWsProxyFactoryBean instance should be called only once, otherwise you get a memory leak:

return factoryBean.create();

factoryBean.create() returns the cxf JAX-WS client proxy, which you can reuse for repeated calls. Created client is also thread safe if you don't use any special features mentioned here http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!