[ http://issues.apache.org/jira/browse/XMLRPC-95?page=all ]

Jochen Wiedmann closed XMLRPC-95.
---------------------------------

    Resolution: Invalid

Ok, here is your fault:

The class you give to the DynamicHandlerMapping is no other than your own 
RpcServer(). Now, when a request comes in, an instance of RpcServer is created, 
in order to call its method "loginUser". In other words: The constructor of 
RpcServer is executed before the loginUser method. In particular, a new 
instance of WebServer with port 3099 is created.

However, this port is no longer free: A first instance of WebServer was already 
created (the instance, which is currently accepting the request), thus the port 
 3099 is blocked and the constructor waits ... and waits ... until the port 
might be free or a timeout occurs.

Fix: Create a new class (for example "LoginHandler") with a default 
constructor, move the "loginUser" method to that class and replace the 
RpcServer.class in the handler mapping with "LoginHandler". That's all.


> Client hangs on execute
> -----------------------
>
>                 Key: XMLRPC-95
>                 URL: http://issues.apache.org/jira/browse/XMLRPC-95
>             Project: XML-RPC
>          Issue Type: Bug
>          Components: Releases
>    Affects Versions: 3.0b1
>         Environment: Win XP
> Java 1.5.0_06
>            Reporter: Bit Buzzer
>
>         Problem description:
>       When this server is running and the client is executed, nothing happens.
>       The client hangs on the "execute" statement, and neither of them throws 
> any exception or message.
>       No indication what goes wrong or were the problem exists.
>       Server code:
>       ###################################################
>       import java.io.IOException;
>       import org.apache.xmlrpc.XmlRpcException;
>       import org.apache.xmlrpc.common.TypeConverterFactoryImpl;
>       import org.apache.xmlrpc.server.DynamicHandlerMapping;
>       import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
>       import org.apache.xmlrpc.webserver.WebServer;
>       public class RpcServer {
>               static int port = 3099;
>               private WebServer server;
>               
>               public static void main(String[] args) {
>                       new RpcServer();
>               }
>               
>               public RpcServer(){
>                       try {
>                               server = new WebServer(port);
>                               XmlRpcServerConfigImpl config = new 
> XmlRpcServerConfigImpl();
>                               config.setEnabledForExtensions(true);
>                               config.setContentLengthOptional(true);
>                               
>                               DynamicHandlerMapping dhm = new 
> DynamicHandlerMapping(new TypeConverterFactoryImpl(), false);
>                               dhm.addHandler("Start", this.getClass());
>                               
>                               server.getXmlRpcServer().setConfig(config);
>                               server.getXmlRpcServer().setHandlerMapping(dhm);
>                               
>                               server.start();
>                               
>                               System.out.println("RPC server running. ");
>                       } 
>                       catch (XmlRpcException e) {
>                               System.out.println("RPC EXcep");
>                               e.printStackTrace();
>                       } 
>                       catch (IOException e) {
>                               System.out.println("IO EXcep");
>                               e.printStackTrace();
>                       }
>               }
>               
>               public int loginUser(String userId ) {
>                       System.out.println("In de method");
>                       return 0;
>                }
>       }
>       ###################################################
>       Server includes following jars:
>         - commons-logging-1.1.jar
>         - ws-commons-util-1.0-SNAPSHOT.jar
>         - xmlrpc-common-3.0b1.jar
>         - xmlrpc-server-3.0b1.jar
>       Client code:
>       ###################################################
>       import java.net.URL;
>       import java.util.List;
>       import java.util.Vector;
>       import org.apache.xmlrpc.client.XmlRpcClient;
>       import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
>       public class RpcClient {
>           static XmlRpcClient xmlrpc;
>           
>           public static void main( String args[] ) {
>               try {
>                   List<String> params = new Vector<String>();
>                   params.add( "48504852" );
>                       
>                       XmlRpcClientConfigImpl config = new 
> XmlRpcClientConfigImpl();
>                       config.setServerURL(new 
> URL("http://192.168.1.1:3099/";));
>                       config.setEnabledForExtensions(true);
>                       config.setContentLengthOptional(true);
>                               
>                       xmlrpc = new XmlRpcClient();
>                       xmlrpc.setConfig(config);
>                       Integer r = (Integer) xmlrpc.execute 
> ("Start.loginUser", params);
>                       System.out.println(r);
>               } catch (Exception e) {
>                   e.printStackTrace();
>               }
>           }
>       }
>       ###################################################
>       Client includes following jars:
>         - ws-commons-util-1.0-SNAPSHOT.jar
>         - xmlrpc-common-3.0b1.jar
>         - xmlrpc-client-3.0b1.jar

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to