You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by Sneha V <sn...@yahoo.com> on 2004/03/23 18:37:41 UTC

java.util.NoSuchElementException

Hi,

I am using xmlrpc-1.2-b1 Webserver on Windows 2000 and
xmlrpc++ client (downloaded from
http://xmlrpcpp.sourceforge.net).

When the client tries to execute a method on the
WebServer, I get the correct response but I get an
error 
"java.util.NoSuchElementException" on the server's
java console. 

Any idea why I am getting this exception and any fix?

Thanks,
sneha

__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

Re: java.util.NoSuchElementException

Posted by Sneha V <sn...@yahoo.com>.
Problem is with the Java Webserver code. It tries to
read a line using readline() method. readline() will
return an empty string if end of stream is reached.
And the Connection::run() method checks if the
readline() returned an empty string and calls
readline() again. readline() will return empty string
again and now Connection::run() tries to parse the
empty string assumming a valid header. So, if the
client closes the connection, Webserver will detect
end of stream and throws a NoSuchElementException.
This could be a valid case, but it prints the
exception on the Java Console window. If you are not
familiar with the code, you would think that there is
some problem with your code.

The below code also prints an error message if the
connection is on and there is no traffic on the
connection for 30secs. On the socket, SetSoTimeout of
30secs is set, so the read() will timeout and readline
will throw an InterruptedIOException and
Connection::run() will print the exception.


Here is the code in Webserver :

public void run()
{
     try
     {
        boolean keepAlive = false;

        do
        {
           // reset user authentication
           user = null;
           password = null;
           String line = readLine();
           // Netscape sends an extra \n\r after
bodypart, swallow it
           if (line != null && line.length() == 0)
           {
              line = readLine();
           }
           if (XmlRpc.debug)
           {
              System.out.println(line);
           }
           int contentLength = -1;
           // tokenize first line of HTTP request
           StringTokenizer tokens = new
StringTokenizer(line);
           String method = tokens.nextToken();
           ...
}

private String readLine() throws IOException
{
     if (buffer == null)
     {
         buffer = new byte[2048];
     }
     int next;
     int count = 0;
     for (;;)
     {
       next = input.read();
       if (next < 0 || next == '\n')
       {
         break;
       }
       if (next != '\r')
       {
         buffer[count++] = (byte) next;
       }
       if (count >= buffer.length)
       {
         throw new IOException("HTTP Header too
long");
       }
     }
     return new String(buffer, 0, count);
 }                    

--- Eric Westfall <ew...@mailcan.com> wrote:
> Well, I don't know anything about the xmlRpc++
> client but I would probably
> suspect the client in this case.  Since you said
> that you still get the
> correct response back, I'm guessing that the server
> may be getting two
> requests, one malformed and the other valid.  Either
> that or the server is
> mangling the request.  I would start by verifying
> that the client is doing
> its job correctly.  If the client is working as
> expected that it might we a
> server problem.  Personally, I've never used the
> WebServer class before.
> I've always run my xmlrpc server as a servlet from
> inside Tomcat which works
> really well.  If you can't get this working, and you
> can determine that its
> not a client issue, I might suggest that.
> 
> Later,
> Eric Westfall
> 
> ----- Original Message ----- 
> From: "Sneha V" <sn...@yahoo.com>
> To: <xm...@ws.apache.org>
> Sent: Thursday, March 25, 2004 10:16 AM
> Subject: Re: java.util.NoSuchElementException
> 
> 
> > You are right. On the Java console window, I saw
> an
> > empty line being printed before the exception
> > happened.  So do you think that the problem is in
> > xmlrpc++ client or in Java webserver?
> >
> > --- Eric Westfall <ew...@mailcan.com> wrote:
> > > Well, looks like that's happening when trying to
> > > read in the http headers from the request. 
> Perhaps
> > > its a problem with the xmlRpc++ client?  Try
> turning
> > > on XmlRpc.debug and see what's printed out for
> the
> > > first line in the request.  I'm guessing its
> going
> > > to be the empty string.
> > >
> > > Hope that helps,
> > > Eric
> > >   ----- Original Message ----- 
> > >   From: Sneha V
> > >   To: xmlrpc-user@ws.apache.org
> > >   Sent: Thursday, March 25, 2004 1:02 AM
> > >   Subject: Re: java.util.NoSuchElementException
> > >
> > >
> > >   Hi,
> > >   Sorry for the delay. Whenever I turn on the
> debug,
> > > the webserver hangs. Luckily this time, I was
> able
> > > to capture the stackTrace.
> > >
> > >   I turned on debug and here is the stacktrace:
> > >
> > >   java.util.NoSuchElementException
> > >   java.util.NoSuchElementException
> > >   at java.util.StringTokenizer.nextToken(Unknown
> > > Source)
> > >   at
> > >
> >
>
org.apache.xmlrpc.WebServer$Connection.run(WebServer.java:734)
> > >   at
> > >
> >
>
org.apache.xmlrpc.WebServer$Runner.run(WebServer.java:656)
> > >   at java.lang.Thread.run(Unknown Source)
> > >
> > >   Also, sometimes the Webserver simply hangs
> when I
> > > turn on debug. This is how I am using xmlRpc:
> > >   1. Java XmlRpcClientLite on windows2000
> connected
> > > to a xmlRpcC++ server on linux.
> > >   2. xmlRpc++ client on linux connected to Java
> > > Webserver on windows 2000.
> > >
> > >   Basically one connection from windows to linux
> and
> > > another connection in the opposite direction.
> > >
> > >   regards,
> > >   shanmuk
> > >
> > >   Eric Westfall <ew...@mailcan.com> wrote:
> > >     Is there a stacktrace printed out with that?
> > >
> > >     ----- Original Message ----- 
> > >     From: "Sneha V"
> > >     To:
> > >     Sent: Tuesday, March 23, 2004 1:17 PM
> > >     Subject: Re:
> java.util.NoSuchElementException
> > >
> > >
> > >     >
> > >     > Forgot to mention that I am running the
> client
> > > on
> > >     > Linux and the server on windows2000.
> > >     >
> > >     > thanks,
> > >     > sneha
> > >     > --- Sneha V wrote:
> > >     > > Hi,
> > >     > >
> > >     > > I am using xmlrpc-1.2-b1 Webserver on
> > > Windows 2000
> > >     > > and
> > >     > > xmlrpc++ client (downloaded from
> > >     > > http://xmlrpcpp.sourceforge.net).
> > >     > >
> > >     > > When the client tries to execute a
> method on
> > > the
> > >     > > WebServer, I get the correct response
> but I
> > > get an
> > >     > > error
> > >     > > "java.util.NoSuchElementException" on
> the
> > > server's
> > >     > > java console.
> > >     > >
> > >     > > Any idea why I am getting this exception
> and
> > > any
> > >     > > fix?
> > >     > >
> > >     > > Thanks,
> > >     > > sneha
> > >     > >
> > >     > > __________________________________
> > >     > > Do you Yahoo!?
> > >     > > Yahoo! Mail - More reliable, more
> storage,
> > > less spam
> > >     > > http://mail.yahoo.com
> > >     >
> > >     >
> > >     > __________________________________
> > >     > Do you Yahoo!?
> > >     > Yahoo! Mail - More reliable, more storage,
> > > less spam
> > >     > http://mail.yahoo.com
> > >     >
> > >   Do you Yahoo!?
> > >   Yahoo! Mail - More reliable, more storage,
> less
> > > spam
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - More reliable, more storage, less
> spam
> > http://mail.yahoo.com
> >
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

Re: java.util.NoSuchElementException

Posted by Eric Westfall <ew...@mailcan.com>.
Well, I don't know anything about the xmlRpc++ client but I would probably
suspect the client in this case.  Since you said that you still get the
correct response back, I'm guessing that the server may be getting two
requests, one malformed and the other valid.  Either that or the server is
mangling the request.  I would start by verifying that the client is doing
its job correctly.  If the client is working as expected that it might we a
server problem.  Personally, I've never used the WebServer class before.
I've always run my xmlrpc server as a servlet from inside Tomcat which works
really well.  If you can't get this working, and you can determine that its
not a client issue, I might suggest that.

Later,
Eric Westfall

----- Original Message ----- 
From: "Sneha V" <sn...@yahoo.com>
To: <xm...@ws.apache.org>
Sent: Thursday, March 25, 2004 10:16 AM
Subject: Re: java.util.NoSuchElementException


> You are right. On the Java console window, I saw an
> empty line being printed before the exception
> happened.  So do you think that the problem is in
> xmlrpc++ client or in Java webserver?
>
> --- Eric Westfall <ew...@mailcan.com> wrote:
> > Well, looks like that's happening when trying to
> > read in the http headers from the request.  Perhaps
> > its a problem with the xmlRpc++ client?  Try turning
> > on XmlRpc.debug and see what's printed out for the
> > first line in the request.  I'm guessing its going
> > to be the empty string.
> >
> > Hope that helps,
> > Eric
> >   ----- Original Message ----- 
> >   From: Sneha V
> >   To: xmlrpc-user@ws.apache.org
> >   Sent: Thursday, March 25, 2004 1:02 AM
> >   Subject: Re: java.util.NoSuchElementException
> >
> >
> >   Hi,
> >   Sorry for the delay. Whenever I turn on the debug,
> > the webserver hangs. Luckily this time, I was able
> > to capture the stackTrace.
> >
> >   I turned on debug and here is the stacktrace:
> >
> >   java.util.NoSuchElementException
> >   java.util.NoSuchElementException
> >   at java.util.StringTokenizer.nextToken(Unknown
> > Source)
> >   at
> >
> org.apache.xmlrpc.WebServer$Connection.run(WebServer.java:734)
> >   at
> >
> org.apache.xmlrpc.WebServer$Runner.run(WebServer.java:656)
> >   at java.lang.Thread.run(Unknown Source)
> >
> >   Also, sometimes the Webserver simply hangs when I
> > turn on debug. This is how I am using xmlRpc:
> >   1. Java XmlRpcClientLite on windows2000 connected
> > to a xmlRpcC++ server on linux.
> >   2. xmlRpc++ client on linux connected to Java
> > Webserver on windows 2000.
> >
> >   Basically one connection from windows to linux and
> > another connection in the opposite direction.
> >
> >   regards,
> >   shanmuk
> >
> >   Eric Westfall <ew...@mailcan.com> wrote:
> >     Is there a stacktrace printed out with that?
> >
> >     ----- Original Message ----- 
> >     From: "Sneha V"
> >     To:
> >     Sent: Tuesday, March 23, 2004 1:17 PM
> >     Subject: Re: java.util.NoSuchElementException
> >
> >
> >     >
> >     > Forgot to mention that I am running the client
> > on
> >     > Linux and the server on windows2000.
> >     >
> >     > thanks,
> >     > sneha
> >     > --- Sneha V wrote:
> >     > > Hi,
> >     > >
> >     > > I am using xmlrpc-1.2-b1 Webserver on
> > Windows 2000
> >     > > and
> >     > > xmlrpc++ client (downloaded from
> >     > > http://xmlrpcpp.sourceforge.net).
> >     > >
> >     > > When the client tries to execute a method on
> > the
> >     > > WebServer, I get the correct response but I
> > get an
> >     > > error
> >     > > "java.util.NoSuchElementException" on the
> > server's
> >     > > java console.
> >     > >
> >     > > Any idea why I am getting this exception and
> > any
> >     > > fix?
> >     > >
> >     > > Thanks,
> >     > > sneha
> >     > >
> >     > > __________________________________
> >     > > Do you Yahoo!?
> >     > > Yahoo! Mail - More reliable, more storage,
> > less spam
> >     > > http://mail.yahoo.com
> >     >
> >     >
> >     > __________________________________
> >     > Do you Yahoo!?
> >     > Yahoo! Mail - More reliable, more storage,
> > less spam
> >     > http://mail.yahoo.com
> >     >
> >   Do you Yahoo!?
> >   Yahoo! Mail - More reliable, more storage, less
> > spam
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
>


Re: java.util.NoSuchElementException

Posted by Sneha V <sn...@yahoo.com>.
You are right. On the Java console window, I saw an
empty line being printed before the exception
happened.  So do you think that the problem is in
xmlrpc++ client or in Java webserver?

--- Eric Westfall <ew...@mailcan.com> wrote:
> Well, looks like that's happening when trying to
> read in the http headers from the request.  Perhaps
> its a problem with the xmlRpc++ client?  Try turning
> on XmlRpc.debug and see what's printed out for the
> first line in the request.  I'm guessing its going
> to be the empty string.
> 
> Hope that helps,
> Eric
>   ----- Original Message ----- 
>   From: Sneha V 
>   To: xmlrpc-user@ws.apache.org 
>   Sent: Thursday, March 25, 2004 1:02 AM
>   Subject: Re: java.util.NoSuchElementException
> 
> 
>   Hi,
>   Sorry for the delay. Whenever I turn on the debug,
> the webserver hangs. Luckily this time, I was able
> to capture the stackTrace.
> 
>   I turned on debug and here is the stacktrace:
> 
>   java.util.NoSuchElementException
>   java.util.NoSuchElementException
>   at java.util.StringTokenizer.nextToken(Unknown
> Source)
>   at
>
org.apache.xmlrpc.WebServer$Connection.run(WebServer.java:734)
>   at
>
org.apache.xmlrpc.WebServer$Runner.run(WebServer.java:656)
>   at java.lang.Thread.run(Unknown Source)
> 
>   Also, sometimes the Webserver simply hangs when I
> turn on debug. This is how I am using xmlRpc:
>   1. Java XmlRpcClientLite on windows2000 connected
> to a xmlRpcC++ server on linux.
>   2. xmlRpc++ client on linux connected to Java
> Webserver on windows 2000.
> 
>   Basically one connection from windows to linux and
> another connection in the opposite direction.
> 
>   regards,
>   shanmuk
> 
>   Eric Westfall <ew...@mailcan.com> wrote:
>     Is there a stacktrace printed out with that?
> 
>     ----- Original Message ----- 
>     From: "Sneha V" 
>     To: 
>     Sent: Tuesday, March 23, 2004 1:17 PM
>     Subject: Re: java.util.NoSuchElementException
> 
> 
>     > 
>     > Forgot to mention that I am running the client
> on
>     > Linux and the server on windows2000.
>     > 
>     > thanks,
>     > sneha
>     > --- Sneha V wrote:
>     > > Hi,
>     > > 
>     > > I am using xmlrpc-1.2-b1 Webserver on
> Windows 2000
>     > > and
>     > > xmlrpc++ client (downloaded from
>     > > http://xmlrpcpp.sourceforge.net).
>     > > 
>     > > When the client tries to execute a method on
> the
>     > > WebServer, I get the correct response but I
> get an
>     > > error 
>     > > "java.util.NoSuchElementException" on the
> server's
>     > > java console. 
>     > > 
>     > > Any idea why I am getting this exception and
> any
>     > > fix?
>     > > 
>     > > Thanks,
>     > > sneha
>     > > 
>     > > __________________________________
>     > > Do you Yahoo!?
>     > > Yahoo! Mail - More reliable, more storage,
> less spam
>     > > http://mail.yahoo.com
>     > 
>     > 
>     > __________________________________
>     > Do you Yahoo!?
>     > Yahoo! Mail - More reliable, more storage,
> less spam
>     > http://mail.yahoo.com
>     > 
>   Do you Yahoo!?
>   Yahoo! Mail - More reliable, more storage, less
> spam
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

Re: java.util.NoSuchElementException

Posted by Eric Westfall <ew...@mailcan.com>.
Well, looks like that's happening when trying to read in the http headers from the request.  Perhaps its a problem with the xmlRpc++ client?  Try turning on XmlRpc.debug and see what's printed out for the first line in the request.  I'm guessing its going to be the empty string.

Hope that helps,
Eric
  ----- Original Message ----- 
  From: Sneha V 
  To: xmlrpc-user@ws.apache.org 
  Sent: Thursday, March 25, 2004 1:02 AM
  Subject: Re: java.util.NoSuchElementException


  Hi,
  Sorry for the delay. Whenever I turn on the debug, the webserver hangs. Luckily this time, I was able to capture the stackTrace.

  I turned on debug and here is the stacktrace:

  java.util.NoSuchElementException
  java.util.NoSuchElementException
  at java.util.StringTokenizer.nextToken(Unknown Source)
  at org.apache.xmlrpc.WebServer$Connection.run(WebServer.java:734)
  at org.apache.xmlrpc.WebServer$Runner.run(WebServer.java:656)
  at java.lang.Thread.run(Unknown Source)

  Also, sometimes the Webserver simply hangs when I turn on debug. This is how I am using xmlRpc:
  1. Java XmlRpcClientLite on windows2000 connected to a xmlRpcC++ server on linux.
  2. xmlRpc++ client on linux connected to Java Webserver on windows 2000.

  Basically one connection from windows to linux and another connection in the opposite direction.

  regards,
  shanmuk

  Eric Westfall <ew...@mailcan.com> wrote:
    Is there a stacktrace printed out with that?

    ----- Original Message ----- 
    From: "Sneha V" 
    To: 
    Sent: Tuesday, March 23, 2004 1:17 PM
    Subject: Re: java.util.NoSuchElementException


    > 
    > Forgot to mention that I am running the client on
    > Linux and the server on windows2000.
    > 
    > thanks,
    > sneha
    > --- Sneha V wrote:
    > > Hi,
    > > 
    > > I am using xmlrpc-1.2-b1 Webserver on Windows 2000
    > > and
    > > xmlrpc++ client (downloaded from
    > > http://xmlrpcpp.sourceforge.net).
    > > 
    > > When the client tries to execute a method on the
    > > WebServer, I get the correct response but I get an
    > > error 
    > > "java.util.NoSuchElementException" on the server's
    > > java console. 
    > > 
    > > Any idea why I am getting this exception and any
    > > fix?
    > > 
    > > Thanks,
    > > sneha
    > > 
    > > __________________________________
    > > Do you Yahoo!?
    > > Yahoo! Mail - More reliable, more storage, less spam
    > > http://mail.yahoo.com
    > 
    > 
    > __________________________________
    > Do you Yahoo!?
    > Yahoo! Mail - More reliable, more storage, less spam
    > http://mail.yahoo.com
    > 
  Do you Yahoo!?
  Yahoo! Mail - More reliable, more storage, less spam

Re: java.util.NoSuchElementException

Posted by Sneha V <sn...@yahoo.com>.
Hi,
Sorry for the delay. Whenever I turn on the debug, the webserver hangs. Luckily this time, I was able to capture the stackTrace.
 
I turned on debug and here is the stacktrace:
 
java.util.NoSuchElementException
java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at org.apache.xmlrpc.WebServer$Connection.run(WebServer.java:734)
at org.apache.xmlrpc.WebServer$Runner.run(WebServer.java:656)
at java.lang.Thread.run(Unknown Source)

Also, sometimes the Webserver simply hangs when I turn on debug. This is how I am using xmlRpc:
1. Java XmlRpcClientLite on windows2000 connected to a xmlRpcC++ server on linux.
2. xmlRpc++ client on linux connected to Java Webserver on windows 2000.
 
Basically one connection from windows to linux and another connection in the opposite direction.
 
regards,
shanmuk

Eric Westfall <ew...@mailcan.com> wrote:
Is there a stacktrace printed out with that?

----- Original Message ----- 
From: "Sneha V" 
To: 
Sent: Tuesday, March 23, 2004 1:17 PM
Subject: Re: java.util.NoSuchElementException


> 
> Forgot to mention that I am running the client on
> Linux and the server on windows2000.
> 
> thanks,
> sneha
> --- Sneha V wrote:
> > Hi,
> > 
> > I am using xmlrpc-1.2-b1 Webserver on Windows 2000
> > and
> > xmlrpc++ client (downloaded from
> > http://xmlrpcpp.sourceforge.net).
> > 
> > When the client tries to execute a method on the
> > WebServer, I get the correct response but I get an
> > error 
> > "java.util.NoSuchElementException" on the server's
> > java console. 
> > 
> > Any idea why I am getting this exception and any
> > fix?
> > 
> > Thanks,
> > sneha
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - More reliable, more storage, less spam
> > http://mail.yahoo.com
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
> 
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam

Re: java.util.NoSuchElementException

Posted by Eric Westfall <ew...@mailcan.com>.
Is there a stacktrace printed out with that?

----- Original Message ----- 
From: "Sneha V" <sn...@yahoo.com>
To: <xm...@ws.apache.org>
Sent: Tuesday, March 23, 2004 1:17 PM
Subject: Re: java.util.NoSuchElementException


> 
> Forgot to mention that I am running the client on
> Linux and the server on windows2000.
> 
> thanks,
> sneha
> --- Sneha V <sn...@yahoo.com> wrote:
> > Hi,
> > 
> > I am using xmlrpc-1.2-b1 Webserver on Windows 2000
> > and
> > xmlrpc++ client (downloaded from
> > http://xmlrpcpp.sourceforge.net).
> > 
> > When the client tries to execute a method on the
> > WebServer, I get the correct response but I get an
> > error 
> > "java.util.NoSuchElementException" on the server's
> > java console. 
> > 
> > Any idea why I am getting this exception and any
> > fix?
> > 
> > Thanks,
> > sneha
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - More reliable, more storage, less spam
> > http://mail.yahoo.com
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
> 

Re: java.util.NoSuchElementException

Posted by Sneha V <sn...@yahoo.com>.
Forgot to mention that I am running the client on
Linux and the server on windows2000.

thanks,
sneha
--- Sneha V <sn...@yahoo.com> wrote:
> Hi,
> 
> I am using xmlrpc-1.2-b1 Webserver on Windows 2000
> and
> xmlrpc++ client (downloaded from
> http://xmlrpcpp.sourceforge.net).
> 
> When the client tries to execute a method on the
> WebServer, I get the correct response but I get an
> error 
> "java.util.NoSuchElementException" on the server's
> java console. 
> 
> Any idea why I am getting this exception and any
> fix?
> 
> Thanks,
> sneha
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com