You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by mith86 <mi...@spanservices.com> on 2011/01/04 06:15:03 UTC

Error using xml-rpc with java code

Hi

I got a java client and server program off the internet and i'm trying to
run it...the server code seems to be fine - it's up and running, but when I
try to run the client program, I get the following error -

Exception in thread "main" java.lang.InstantiationError:
org.apache.xmlrpc.XmlRpcRequest
	at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:177)
	at JavaClient.main(JavaClient.java:16)

Here's my client code -

import java.util.*;
import org.apache.xmlrpc.*;

public class JavaClient 
{
	public static void main(String[] args) 
	{
		try 
		{
			XmlRpcClient client = new XmlRpcClient("http://localhost:8901/");
			Vector params = new Vector();
			params.addElement(new Integer(17));
			params.addElement(new Integer(13));

			Object result = client.execute("sample.sum", params);

			int sum = ((Integer) result).intValue();
			System.out.println("The sum is: " + sum);

		} 
		catch (Exception exception) 
		{
			System.err.println("JavaClient: " + exception);
		}
	}
}


And here's my server code - 

import org.apache.xmlrpc.WebServer;

public class JavaServer 
{
	public Integer sum(int x, int y) 
	{
		return new Integer(x + y);
	}

	public static void main(String[] args) 
	{
		try 
		{
			System.out.println("Attempting to start XML-RPC Server...");
			WebServer server = new WebServer(8901);
			server.setParanoid(true);
			server.acceptClient("127.0.0.1");
			server.addHandler("sample", new JavaServer());
			server.start();
			System.out.println("Started successfully.");
			System.out.println("Accepting requests. (Halt program to stop.)");
		} 
		catch (Exception exception) 
		{
			System.err.println("JavaServer: " + exception);
		}
	}
}

Does anybody know what could be the problem? Any help would be much
appreciated!
-- 
View this message in context: http://old.nabble.com/Error-using-xml-rpc-with-java-code-tp30583985p30583985.html
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org


Re: Error using xml-rpc with java code

Posted by Jochen Wiedmann <jo...@gmail.com>.
Trap the exception and get a stacktrace of the throwable, which is
embedded in the error.


On Tue, Jan 4, 2011 at 6:15 AM, mith86 <mi...@spanservices.com> wrote:
>
> Hi
>
> I got a java client and server program off the internet and i'm trying to
> run it...the server code seems to be fine - it's up and running, but when I
> try to run the client program, I get the following error -
>
> Exception in thread "main" java.lang.InstantiationError:
> org.apache.xmlrpc.XmlRpcRequest
>        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:177)
>        at JavaClient.main(JavaClient.java:16)
>
> Here's my client code -
>
> import java.util.*;
> import org.apache.xmlrpc.*;
>
> public class JavaClient
> {
>        public static void main(String[] args)
>        {
>                try
>                {
>                        XmlRpcClient client = new XmlRpcClient("http://localhost:8901/");
>                        Vector params = new Vector();
>                        params.addElement(new Integer(17));
>                        params.addElement(new Integer(13));
>
>                        Object result = client.execute("sample.sum", params);
>
>                        int sum = ((Integer) result).intValue();
>                        System.out.println("The sum is: " + sum);
>
>                }
>                catch (Exception exception)
>                {
>                        System.err.println("JavaClient: " + exception);
>                }
>        }
> }
>
>
> And here's my server code -
>
> import org.apache.xmlrpc.WebServer;
>
> public class JavaServer
> {
>        public Integer sum(int x, int y)
>        {
>                return new Integer(x + y);
>        }
>
>        public static void main(String[] args)
>        {
>                try
>                {
>                        System.out.println("Attempting to start XML-RPC Server...");
>                        WebServer server = new WebServer(8901);
>                        server.setParanoid(true);
>                        server.acceptClient("127.0.0.1");
>                        server.addHandler("sample", new JavaServer());
>                        server.start();
>                        System.out.println("Started successfully.");
>                        System.out.println("Accepting requests. (Halt program to stop.)");
>                }
>                catch (Exception exception)
>                {
>                        System.err.println("JavaServer: " + exception);
>                }
>        }
> }
>
> Does anybody know what could be the problem? Any help would be much
> appreciated!
> --
> View this message in context: http://old.nabble.com/Error-using-xml-rpc-with-java-code-tp30583985p30583985.html
> Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: dev-help@ws.apache.org
>
>



-- 
I Am What I Am And That's All What I Yam (Popeye)