9 Replies Latest reply: Jul 14, 2011 3:23 AM by 857112 RSS

    apache xml rpc - HTTP server returned unexpected status: Not Found error

    584284
      org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Not Found
           at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)
           at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)
           at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
           at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
           at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
           at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
           at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)
           at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)
           at org.apache.xmlrpc.demo.SimpleClient.<init>(SimpleClient.java:18)
           at org.apache.xmlrpc.demo.SimpleClient.main(SimpleClient.java:26)

      I get this error every time I run my client program. I haven't been able to figure out the cause of this error. At line 18 of SimpleClient.java, I have the following statement:
      Integer result = (Integer) client.execute("Calculator.add", params);


      I can post the complete source code if needed. Thanks!
        • 1. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
          EJP
          The cause of it is that the URL doesn't exist.
          • 2. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
            584284
            you mean something with "Calculator.add" ? If you know what I should be looking for or change in the code, it would be helpful.
            • 3. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
              EJP
              Either that or the URL, wherever in your unseen code it is specified. Probably when you construct or connect 'client'.
              • 4. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
                635105
                Verify again the file XmlRpcServlet.properties!

                1. this file must have this line:
                Calculator=org.apache.xmlrpc.demo.Calculator
                2. the property file must be called XmlRpcServlet.properties, and it must be located in the package org.apache.xmlrpc.webserver


                Testcase:

                1. When I rename or change the XmlRpcServlet.properties like this
                Calculator=org.apache.xmlrpc.demo.Calculator*X <--*

                I get this (your question)
                Try to add 2 + 3 via XML-RPC...
                org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Internal Server Error
                     at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)
                     at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)
                     at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
                     at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
                     at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
                     at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
                     at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)
                     at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)
                     at org.apache.xmlrpc.demo.SimpleClient.<init>(SimpleClient.java:18)
                     at org.apache.xmlrpc.demo.SimpleClient.main(SimpleClient.java:26)
                2. ..and when you forget to start the server before, you get other error:
                Try to add 2 + 3 via XML-RPC...
                org.apache.xmlrpc.XmlRpcException: Failed to read server's response: Connection refused: connect
                     at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:161)
                     at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
                     at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
                     at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
                     at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
                     at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)
                     at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)
                     at org.apache.xmlrpc.demo.SimpleClient.<init>(SimpleClient.java:18)
                     at org.apache.xmlrpc.demo.SimpleClient.main(SimpleClient.java:26)
                more: see my comment in this post http://d-h-n.de/blog/?p=618
                • 5. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
                  584284
                  hey.. I figured out the problem.. It was with my server url :) -- I wa following the steps as mentioned on your blog last night and left a comment there too! That was really helpful.

                  Another question about the .properties file, how can I have multiple entries in it ? I want the client to be able to call two different methods from two different classes.. let's say one would be Calculator.Add and other RNG.getRandom ?

                  Thanks!
                  • 6. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
                    857112
                    Hi,

                    How did you resolve the problem. What did you changed the url to?

                    I also follwed the exact steps provided by doan's blog but still having the error..

                    (I changed this http://127.0.0.1:8080/xmlrpctest/xmlrpc to http://localhost:8080/xmlrpctest/xmlrpc)

                    Entering the changed url to browser results ::> HTTP Status 405 - HTTP method GET is not supported by this URL

                    I guess the servlet is deployed correctly since 405 is returned but I could not figure out the exception on client side.

                    Please suggest this is urgent.

                    Thanks regards..
                    • 7. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
                      635105
                      Look again file SimpleClient.java

                      config.setServerURL(new URL(
                      "http://127.0.0.1:8080/xmlrpctest/xmlrpc"));


                      1. "xmlrpctest" must be your projectname


                      2. and "xmlrpc" must be found in file web.xml:
                      ..
                      <url-pattern>/xmlrpc</url-pattern>
                      ..
                      • 8. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
                        857112
                        Hi doan,

                        First of all thanks for the help.

                        But the settings are true and I am still having the error. I see that you provided your code sample on your own blog. Even importing your sample to my eclipse and running with tom cat 6 DOES give the same error:((((.

                        Another thing, I tried another sample described at http://my.opera.com/luyaowu/blog/xmlrpc-server-and-client

                        There the approach is very similar to yours. Luyao explicitly overrides XmlRpcServlet. His client is nearly the same with yours. I included the extra method public void doGet(HttpServletRequest request, HttpServletResponse response) in Luyao's servlet.


                        package servlets;

                        import java.io.IOException;
                        import java.io.PrintWriter;

                        import javax.servlet.ServletException;
                        import javax.servlet.http.HttpServletRequest;
                        import javax.servlet.http.HttpServletResponse;

                        import org.apache.xmlrpc.XmlRpcException;
                        import org.apache.xmlrpc.server.PropertyHandlerMapping;
                        import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
                        import org.apache.xmlrpc.webserver.XmlRpcServlet;

                        public class MyXmlRpcServer extends XmlRpcServlet {
                             private static final long serialVersionUID = -1785749750576891337L;

                             protected XmlRpcHandlerMapping newXmlRpcHandlerMapping()
                                       throws XmlRpcException {
                                  PropertyHandlerMapping phm = new PropertyHandlerMapping();
                                  phm.addHandler("myHandler", functions.MyHandler.class);
                                  return phm;
                             }
                             
                             @Override
                             public void doGet(HttpServletRequest request,
                             HttpServletResponse response)
                             throws ServletException, IOException {
                             response.setContentType("text/html");
                             PrintWriter out = response.getWriter();
                             out.println
                             ("<!DOCTYPE html>\n" +
                             "<html>\n" +
                             "<head><title>test</title></head>\n" +
                             "<body bgcolor=\"#fdf5e6\">\n" +
                             "<h1>test</h1>\n" +
                             "<p>test</p>\n" +
                             "</body></html>");
                             }
                        }

                        When I start tomcat and enter the correct url, I got the page html page displayed correctly. But the xml/rpc client is returning the exact error.

                        I am completely stuck now any idea?
                        • 9. Re: apache xml rpc - HTTP server returned unexpected status: Not Found error
                          857112
                          Hi all,

                          Any idea on this? I am still having the problem. I think the problem is in the client side (since the overloaded doGet() returns the expected html page on web browser) but code for the client side is very simple and I am completely stuck. Any help would be very appreciated...