Hi all,
I am trying to set up a XML RPC server using the apache API. Initially I followed the following example
ws-xmlrpc - The Apache XML-RPC Client
about how to set up a simple client-server for exchanging XML RPC request and response. The example we are talking about is the "calculator" simple example.
Once the server is set up, the client just execute the request like

Integer result = (Integer) client.execute("Calculator.add", params);

and get the reply back.
So far, so good.
The problem is the following: the server create an instance of the calculator object EACH TIME A REQUEST ARRIVE TO THE SERVER. This is not suitable for my purposes, as the matter of the fact I have a big slow class, that performs lots of operations when creating the object. For this reason this solution is not suitable for me. For giving you an idea I modified the Calculator class as follows:

public class Calculator {

public Calculator() {
try {
} catch (InterruptedException ex) {
Logger.getLogger(Calculator.class.getName()).log(L evel.SEVERE, null, ex);

public int add(int i1, int i2) {

return i1 + i2;


public int subtract(int i1, int i2) {

return i1 - i2;


and in this case the response take up to 10 second to be computed.... This is not good for me... what can I do to solve this problem? At the moment I am trying to modify XmlRpcServlet and XmlRpcServletServer source code, but I am sure there is a more straightforward solution for this... is there a way to keep the calculator obj always alive somewhere for handling the requests? PLEASE HELP! I really appreciate your help.
Many thanks