Cześć,

mam następujący problem...

System nad którym pracuję składa się z dwóch części (obie napisane w Javie):

  • server logiki biznesowej - działający jako normalna aplikacja ("standalone"),
  • aplikacja webowa (wykonana na frameworku Turbine, postawiona na Resin Application Server) - działa jako warstwa prezentacji.

Te dwie części połączone są poprzez mechanizm socketów po TCP/IP - używamy głownie ObjectOutputStream'ów.

Normalnie wszystko chodzi dobrze (system działa już na kilku różnych serwerach w kilku lokalizacjach), ale niedawno postawiliśmy go na nowej maszynie i zaczął nam rzucać dziwne wyjątki. Poniżej przedstawiam informacje o serwerze, wyjątkach i kodzie którym się łączymy.

Wydaje nam się, że może chodzić o konfigurację jądra, może o stos TCP/IP, ale o co konkretnie to nie mamy pomysłu.
Z góry dzięki za pomoc.

Server:
Maszyna: Sun T2000

System: Solaris 10

JVM: 1.4 or 1.5 (both were tested)

Wyjatki:
ERROR 2006-11-28 11:28:59,377 [pl.com.ttsoft.vixen.currentday.server.ClientServiceThread] - IOException while sending data to the client. Closing output stream.
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1682)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1591)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1401)
at java.io.ObjectOutputStream.writeUnshared(ObjectOutputStream.java:371)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.sendMessageToClient(ClientServiceThread.java:679)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.sendModificationData(ClientServiceThread.java:432)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.serveDataModification(ClientServiceThread.java:308)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.run(ClientServiceThread.java:185)

ERROR 2006-11-28 11:28:59,400 [pl.com.ttsoft.vixen.currentday.server.ClientServiceThread] - IOException while closing client connection.
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1682)
at java.io.ObjectOutputStream$BlockDataOutputStream.flush(ObjectOutputStream.java:1627)
at java.io.ObjectOutputStream.flush(ObjectOutputStream.java:666)
at java.io.ObjectOutputStream.close(ObjectOutputStream.java:687)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.closeClientConnection(ClientServiceThread.java:706)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.sendMessageToClient(ClientServiceThread.java:691)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.sendModificationData(ClientServiceThread.java:432)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.serveDataModification(ClientServiceThread.java:308)
at pl.com.ttsoft.vixen.currentday.server.ClientServiceThread.run(ClientServiceThread.java:185)

Kod:

STANDALONE APPLICATION CODE:

/ i've simplified it /

/ OPENING CONNECITON /

      Socket socket = = new Socket(hostName, hostPort);
      ObjectOutputStream outStream = new ObjectOutputStream( socket.getOutputStream() );

      ClientDescriptor clientDescriptor = 
        new ClientDescriptor(socket, outStream, info.getLogin(), info.getSystem(),
            info.getDay(), info.getCurrentDaySessionId());

/ SENDING DATA /

 private boolean sendMessageToClient( MessageDTO messageDTO, ClientDescriptor clientDescriptor ) 
      throws CurrentDayException {

      logger.info( "sendMessageToClient " + messageDTO.getClientId() );

      ObjectOutputStream outputStream = clientDescriptor.getOutputStream();

      try {
          outputStream.writeUnshared( messageDTO ); // THIS WRITE THROWS EXCEPTIONS
          outputStream.flush();
      } catch ( IOException exc ) {

        logger.error( " IOException while sending data to the client. Closing output stream. ", exc );

        // close client connection 
        //
        closeClientConnection( clientDescriptor );
        return false;
    }
    return true;        
}

private void closeClientConnection( ClientDescriptor clientDescriptor ) {
    try {
        synchronized ( clientDescriptorMap ) {
            clientDescriptor.setState( ClientDescriptor.TO_REMOVE );            
            clientDescriptor.getOutputStream().close();
            clientDescriptor.getSocket().close();
        }
    } catch ( IOException exc ) {
        logger.error( " IOException while closing client connection. ", exc );
    }
}

/ WEB APPLICATION /

/ RECIEVING DATA /
/ it routes this data to 3-rd party applet /

    SocketChannel vixenSocket = (SocketChannel)key.channel();
    Socket clientSocket = (Socket)objClientServers.get(key);

    // read the information from the socket....
    ByteBuffer buffer = ByteBuffer.allocate(16 * 1024);
    while (vixenSocket.read(buffer) > 0) {
        buffer.flip();
        byte[] bytespassed = new byte[buffer.remaining()];

        logger.debug("buffer.remaining() (1)=" + buffer.remaining());

        buffer.get(bytespassed, 0, bytespassed.length);
        clientSocket.getOutputStream().write(bytespassed);
        buffer.compact();
    }
    buffer.flip();
    while (buffer.hasRemaining()) { // make sure the buffer is fully readed.
        byte[] bytespassed = new byte[buffer.remaining()];

        logger.debug("buffer.remaining() (2)=" + buffer.remaining());

        buffer.get(bytespassed, 0, bytespassed.length);
        clientSocket.getOutputStream().write(bytespassed);
    }
    buffer.clear();

</b>