----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Jean-Luc:

I was not being clear.  We have only changed the platform of the Web Server
piece:

Before (1 box):
Web Server/JServ on one box.  Sun e250 Solaris 2.7 w/JDK 1.1.8_09a.  JServ
1.1b3

After (2 boxes):
Web Server:
Intel Linux RH6.1 Apache 1.3.9

JServ:
Sun e250 Solaris 2.7 w/JDK 1.1.8_09a JServ 1.1b3

As I said in the previous note, what we are doing is a Multi-Part file
upload.  I will try to get you a succint demonstration of the problem.  For
now, what we are doing roughly is (I know that we are using a BufferedReader
rather than a BufferedInputStream, but this never caused a problem before).  I
will work on the test scenario to let you know if that makes a difference:

Find the content-type:

      String contentType = req.getContentType();
      String boundaryString = null;
      if (contentType!=null) {
        int semicolon = contentType.indexOf(";");
        int boundary = contentType.indexOf("boundary=");
        // save boundary string and content type
        if (boundary != -1) {
          boundaryString = contentType.substring(boundary+9);
        }
        if (semicolon != -1){
          //trim contentType upto before the first semicolon.
          contentType = contentType.substring(0,semicolon);
        }
      }

Load into Multi-Part:
        contentType.equals("multipart/form-data")) {
        try {
          // #### from multipart request ####

          MultiPartForm mpf = new MultiPartForm(req, boundaryString);
          // place parameters in context and get fileVect
          Vector fileVect = mpf.readFormData(context);

Here's the rough Multi-Part code:

    public Vector readFormData (StringHashtable context)
      throws IOException, WeaselException
    {
        int bsLen = bs.length();
        char[] c = new char[4096];
        int numTries = 0;
        FastStringBuffer sb = FastBufferPoolMgr.getNewFastStringBuffer();
        InputStream instream = req.getInputStream();
        BufferedReader br = new BufferedReader( new InputStreamReader
(instream)
 );
        Vector fileVect = new Vector();

        // read in 4K chunks

        /**
         * for separate JServ/Apache instances the following code is needed to
handle
         * some subtle I/O differences. The same code will bomb if it is
         * used for JServ/Apache combo boxes
         */


//      for (numTries = 0; !br.ready() && numTries < MAX_NUM_TRIES;
numTries++)
{
//        Timer.runTimer();
//      }
//      if (!br.ready()) {
//        throw new WeaselException("MultipartFormData.readFormData: could not
r
ead input stream -> #tries = "+numTries);
//      }

        int len = br.read(c,0,4096);

        while (len >= 0) {
          // append to the stringbuffer
          if (len > 0) sb.append(c,0,len);

          /**
           * for separate JServ/Apache instances the following code is needed
to
 handle
           * some subtle I/O differences. The same code will bomb if it is
           * used for JServ/Apache combo boxes
           */
//        for (numTries = 0; !br.ready() && numTries < MAX_NUM_TRIES;
numTries++
) {
//          Timer.runTimer();
//        }
//        if (!br.ready()) {
//          break;
//        }

          len = br.read(c,0,4096);
        }

        // convert string buffer to string
        String mpd = sb.toString();
                FastBufferPoolMgr.returnFastStringBuffer(sb);
        // loop through the form looking for the boundary string


Jean-Luc Rochat wrote:

> ----------------------------------------------------------------
> BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
> WHEN YOU POST, include all relevant version numbers, log files,
> and configuration files.  Don't make us guess your problem!!!
> ----------------------------------------------------------------
>
> Michael Amster wrote:
> >
> > Hi:
> >
> > We have been developing a site using Apache JServ 1.1b3 on Sun Solaris
> > 2.7 with JVM 1.1.8_09 and Apache 1.3.9.  During development we had
> > apache and JServ on a single box and all worked well.
> >
> > Now we are going to production with a load balancing.  We have Apache
> > 1.3.9 running on 2 Intel Linux boxes running RH6.1.
> >
> > It seems that any input stream behavior does not work reliably, in
> > particular POST operations and multi-part form reading.
> >
> > We see that I/O is acting very differently on the separated setup.  It
> > looks like what is good for the goose is not good for the different
> > production architecture. Yesterday I made some changes in the
> > Multipart form implementation to handle the case of the stream not being
> >
> > available. It turns out that there is something truly different,
> > I/O-wise, between having Apache/JServ on one box and having them on
> > separate boxes. In other words one multipart implementation does not
> > satisfy both scenarios. The change I made to fix the production setup
> > was bombing out on the development setup. Here is the gist:
> >
> > On one box ->
> >         1. the input stream always seems to report not ready and no
> > bytes
> >         available.
> >         2. calls to read() simply work and and return non-zero lengths
> > until
> >         the end of file is reached. this (I believe) is the way things
> >         are supposed to work.
> >
> > On 2 boxes ->
> >         1. the input stream correctly reports if it is ready with calls
> >         to ready(). the fix I had was to wait until the stream was ready
> >
> >         before each read.
> >         2. calls to read when the stream was not ready would hang the vm
> >
> >         3. discovery of EOF was due to a wait for a finite amount of
> > time
> >         without the stream being ready.    I.E. read() never returns
> > negative number.
> >
> > Any help really appreciated.
> >
> > Thanks,
>
> Hi,
>
> difficult to imagine what's happening, because you changed 4 parameters
> at the same time :
> the OS (from Solaris to Linux), the JVM, separated Apache & JServ on 2
> machines, and used load-balancing.
> The test I'd try : run Apache on 1 linux box & JServ on the "less
> unstable" JVM (Solaris).
> You can use load-balancing here. just don't start JServ ont the Linux
> box.
> And see what's happening. If it works, you've something wrong either
> with Linux (glibc version?), either with the JVM.
> Believe me load-balancing is working on Solaris. Seems to be working on
> Linux too.
> Send me an exemple of a servlet causing problems, and I'll try it here.
>
> Jean-Luc
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Archives and Other:  <http://java.apache.org/main/mail.html>
> Problems?:           [EMAIL PROTECTED]

--
~-~-~-~-~-~-~-~-~-~-~-~-~-~-WEBEASY-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Michael Amster                     [EMAIL PROTECTED]
1148 4th Street, Suite 204     Tel: 310.576.0770
Santa Monica, CA 90403      Fax: 310.576.2011




--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to