Results 1 to 3 of 3
  1. #1
    DerekRaimann is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default XmlRpc - can't get it to work!

    I am trying to use XmlRpc 2.0, which I downloaded at http://workbench.cadenhead.org/files...xmlrpc-2.0.zip. I set up the Classpath to point to the xmlrpc-2.0.jar and xmlrpc-2.0-applet.jar files. This is the code I am trying to run:

    Java Code:
    	import java.io.*;
    	import java.net.*;
    	import java.util.*;
    	import org.apache.xmlrpc.*;
    
    	public class AdvogatoClient {
    		XmlRpcClient client;
    		
    		public AdvogatoClient() {
    			this("http://www.advogato.org:80/XMLRPC");
    		}
    		
    		public AdvogatoClient(String server) {
    			try {
    				client = new XmlRpcClient(server);
    			} catch (MalformedURLException exception) {
    				System.out.println("Bad URL: " + server);
    			}
    		}
    		
    		public Integer getEntryCount(String username) 
    			throws IOException, XmlRpcException {
    				
    			Vector<String> params = new Vector<String>();
    			params.add(username);
    			Integer result = (Integer) client.execute("diary.len", params);
    			return result;
    		}
    		
    		public String getEntry(String username, Integer index) 
    			throws IOException, XmlRpcException {
    				
    			Vector<Object> params = new Vector<Object>();
    			params.add(username);
    			params.add(index);
    			String result = (String) client.execute("diary.get", params);
    			return result;
    		}
    		
    		public static void main(String[] arguments) {
    			if (arguments.length < 1) {
    				System.out.println("Usage: java AdvogatoClient username");
    				System.exit(-1);
    			}
    			try {
    				AdvogatoClient advo;
    				advo = new AdvogatoClient();
    				int entryCount = advo.getEntryCount(arguments[0]);
    				for (int i = 0; i < entryCount; i++) {
    					String entry = advo.getEntry(arguments[0], i);
    					System.out.println(entry);
    				}
    				System.out.println("");
    			} catch (Exception exception) {
    				System.out.println("Error: " + exception.getMessage());
    				exception.printStackTrace();
    			}
    		}
    	}
    The command line I am running is: java AdvogatoClient rcaden

    This is supposed to return information from the server in the code. Instead I get the following error messages:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
    at org.apache.xmlrpc.XmlRpc.createTypeFactory(XmlRpc. java:238)
    at org.apache.xmlrpc.XmlRpc.<init>(XmlRpc.java:193)
    at org.apache.xmlrpc.XmlRpcClientResponseProcessor.<i nit>(XmlRpcClientResponseProcessor.java:48)
    at org.apache.xmlrpc.XmlRpcClientWorker.<init>(XmlRpc ClientWorker.java:43)
    at org.apache.xmlrpc.XmlRpcClient.getWorker(XmlRpcCli ent.java:347)
    at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClien t.java:190)
    at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClien t.java:184)
    at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClien t.java:177)
    at AdvogatoClient.getEntryCount(AdvogatoClient.java:2 6)
    at AdvogatoClient.main(AdvogatoClient.java:48)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 10 more

    Can anyone please tell me what I am doing wrong? Thank you for your help!!!!!!!

    -Derek Raimann

  2. #2
    judejegan is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default XmlRpc - can't get it to work!

    Hi,

    You have to search commons-codec-1.4.jar file.Then add the jar file to project class path. It will be run .
    :)

  3. #3
    DerekRaimann is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default

    That fixed the problem, thank you so much for your help!!! :)

    -Derek

Similar Threads

  1. xmlrpc-2.0.jar doc
    By dewitrydan in forum New To Java
    Replies: 0
    Last Post: 11-23-2010, 10:31 AM
  2. using xmlrpc in java
    By tah_206207 in forum New To Java
    Replies: 0
    Last Post: 11-09-2010, 08:01 PM
  3. xmlrpc returns unexpected status
    By BigBear in forum Java Servlet
    Replies: 2
    Last Post: 07-01-2010, 09:20 PM
  4. Why doesn't this work?
    By Corder10 in forum New To Java
    Replies: 1
    Last Post: 07-04-2009, 10:33 PM
  5. how would i get this to work...?
    By deeadeed in forum New To Java
    Replies: 6
    Last Post: 12-06-2007, 02:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •