RMI file tranfert

Hi,
i have this problem, i have to implement a RMI method through which i'd like to send and receive files. The problem is that the only way that i know to transfer files is: open a serversocket, wait a socket client connection, and than trasfer the file using FileInputStream and FileOutputStream.
The problem of this solution is that when the client call this remote method, the method start on server but it remain blocked, because waiting the client socket. Also the client remain blocked and can't create a socket because is waiting that the remote method finish, before continue running its istructions.
So someone can suggest me a different solution, or a solution for this problem?
Thanks
Alessandro

One easy way to send a file through RMI is to read all bytes of a file to a byte array and send this array as a parameter of a remote method. But of course you may have problems with memory when you send large files. The receive is simillary.
Other way is to split the file and getting slices of the file, sending slices and re-assemble at destination. This assume that the file isn't changed through the full transfering is concluded.
I hope these could help you.

Similar Messages

  • How to send a file using RMI

    hello,,
    I do one program using RMI that shoud transfer a file.. I compiles and no errors .while i am trying to execute this program i found some exception .
    rmiUnmarshalling exception and writeAborted Exception.
    ////Server.java
    import java.rmi.*;
    import java.rmi.server.*;
    import java.io.*;
    public class Server extends UnicastRemoteObject implements serverInterface
         private InputStream in;
         String filename;     
         public Server(String filename) throws RemoteException
              this.filename = filename;          
         public InputStream send() throws RemoteException
              try
                   in = new FileInputStream(filename);
                   int c;
                   while((c = in.read()) != -1)
                        System.out.println((char)c);
              catch(Exception ex)
                   System.out.println("Exception in impl : "+ex);
              return in;
         public static void main(String arg[])
              try
                   Naming.rebind("Server" , new Server("E:\\muthukumar\\RMI\\files\\interinter.java"));
                   System.out.println("Server is ready");
              catch(Exception e)
                   System.out.println("Exception in server : "+e);
    /// serverInterface.java
    import java.rmi.*;
    import java.io.*;
    public interface serverInterface extends Remote
         public InputStream send() throws RemoteException;
    ///Client.java
    import java.rmi.*;
    import java.rmi.server.*;
    import java.io.*;
    class Client
         public static void main(String arg[])
              try
                   serverInterface inter= (serverInterface)Naming.lookup("//localhost/Server");
                   InputStream in = inter.send();
                   int c;     
                   while((c = in.read()) != -1)
                        System.out.println((char)c);
              catch(Exception e)
                   System.out.println("Exception in client : "+e);
    please help me...
    thanks in advance..
    regards,
    Muthukumar

    If you know the file is too large to send as one chunk, then call different methods where you have a method to start saving the file then a method that saves chunks at a time and then a close when you're done. Otherwise, you could probably open a socket stream and have a reader on the client side and a writer on the server side.
    There are probably better ways to transfer files for sure. RMI is Remote Method Invocation similar to a Windows RPC (Remote Procedure Call) so that you can run some code on one machine from another. Streams and sockets are probably better for transfer. Another way you could do it is to use RMI to start up a socket listener like, but not limited to, FTP and then send the file through that API and then you could use RMI to stop the listener when you're done so it is only available when you need it. Even easier is to just have an FTP server running and transfer the file with the API. You can even use FTPS and you don't have to bother with the encryption to protect the data over the net.

  • Java.rmi.server.SkeletonMismatchException: interface hash mismatch

    I am trying to get a MBORemoteSet from the session, which actually gives me the list from the database table. when i click on a combo box returning me the list using the MBOSetRemote object it throws me the exception.
    could not load the labor codes from Maximo
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.server.SkeletonMismatchException: interface hash mismatch
    java.rmi.server.SkeletonMismatchException: interface hash mismatch      
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:240)      
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)      
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:349)      
    at worktech.app.labor.WTLaborSet_Stub.setWhere(Unknown Source)

    Well this error occurs if the RMI files are different on the server and client side.
    It basically tells you that the stub and skeleton don't match with each other. Get the latest version of the RMI jar file or whatever file you are using on the server side to replace the file you are using oon the client side. This would make stub and skeletons to communicate with each other effectively . enjoy :)

  • Jabber file transfert from lan trouble

    Hi,
    My mac is on a lan, I can receive incoming jabber file transferts but cannot send files.
    this is the xml query sent by ichat :
    <iq from='[email protected]/mac' to='[email protected]/gajim' type='set' id='iChat_78811B90'>
    <query xmlns='http://jabber.org/protocol/bytestreams' sid='sid_8F5B6449'>
    <streamhost jid='[email protected]/mac' host='192.168.0.1' port='57637'/>
    </query>
    </iq>
    As you can see ichat send the lan IP, not the public IP.
    Also, the jabber server user (ejabberd 2.0.3) provide a file transfert proxy, but ichat seems to ignore it.
    Is there a way to use file tranferts proxies for outgoing jabber file transferts in ichat ?
    thx

    I would ask here
    http://www.ejabberd.im/
    11:34 PM Thursday; April 2, 2009

  • Create a jar from RMI

    Hi everyone
    I have a RMI application functioning ok but I want to create a jar file to deploy in two computers.
    How do I create a jar file from RMI files?
    Regards

    Are you shure?No, I am sure. Did you have some reason for believing I'm wrong?
    Do you have an example?Yes.
    I saw this link:
    http://java.sun.com/docs/books/tutorial/rmi/compiling.html
    it explains a part of what you say.Exactly. So why are you asking me whether I'm sure?
    Please gave a look to itWhy? I already know the answer.

  • Help me with this RMI example

    For Filetransfering over RMI (with compressing the data on client side and decompressing on server side) :
    I have in Server-Side as a remote methode :
    public byte[] getFileData(String fileName) {
    System.out.println("read : "+fileName);
    try {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DeflaterOutputStream zipOut = new DeflaterOutputStream(out);
    File f=new File(fileName);
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
    int read = 0;
    int len = 0;
    byte data[] = new byte[8192];
    while ((read = in.read(data,0,8192)) != -1) {
    zipOut.write(data,0,read);
    len += read;
    in.close();
    zipOut.close();
    System.out.println("compress-factor : "+len+" to "+out.size()+" bytes");
    return out.toByteArray();
    } catch (Exception e) {
    System.err.println(e);
    return null;
    In Client-Side :
    ... in main programme
    ServerImpl rmi = (ServerImpl)Naming.lookup(rmiName);
    And i have this methode in client side in order to call the remote methode which is on server
    public InputStream getFileData(String fileName) {
    try {
    ByteArrayInputStream zipIn = new ByteArrayInputStream(rmi.getFileData(fileName));// read file
    return new InflaterInputStream(zipIn); // data decompress
    } catch(NullPointerException e) {
    return null; // file could not be opened
    } catch(Exception e) {
    return null;
    My question is where should i call this method, and should i declare this one Remote methode too.
    for using Client-Side i have :
    ==================
    get a property-file :
    Properties pConfig = new Properties();
    URL f = null;
    try {
    InputStream fi = clientImpl.getFileData(PROPERTYFILE);
    pConfig.load(fi);
    fi.close();
    } catch (Exception e) {
    String err = "Can't open property-file on server : "+PROPERTYFILE+" Exception="+e;
    System.out.println(err);
    System.exit(1);
    I have problem to know where should i put this part of code : on client side in main programe, or on server side as a remote methode wich would be called by the client.
    Could some body help me to get organized with thise tree part of code.
    Tank's
    Astiage.

    Here the full sourcecode of my RMI-File-Transfer pattern.
    Sorry for the german comment.
    File : IServerImpl.java
    import java.rmi.RemoteException;
    public interface IServerImpl extends java.rmi.Remote {
      public byte[] getFileData         (String pathname) throws RemoteException;
    File : ServerImpl.java
    /** RMI-Handler */
    import java.util.Date;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    import java.util.zip.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    * alle RMI's f�r den Clients und alle Aufrufe Richtung Clients
    * @author Uwe G�nther
    * @version 20.10.00
    public class ServerImpl extends UnicastRemoteObject implements IServerImpl {
      public ServerImpl(String name) throws RemoteException {
        super();
        try {
          Naming.rebind(name+"/Server_instance",this);
        catch (Exception e) {
          if (e instanceof RemoteException) throw (RemoteException)e;
          else throw new RemoteException(e.getMessage());
       * Ab hier stehen alle Methoden Richtung Server (Aufrufe f�r den Client),
       * jeder Methodenaufruf vom Client bekommt einen eigenen Thread (dank RMI) verpasst,
       * somit k�nnen mehrere Clients eine Methode gleichzeitig aufrufen.
       * -> Nebenl�ufigkeit ist erf�llt,
       *    Methoden k�nnen mehrere Sekunden/Stunden abtauchen ohne andere Clients zu bremsen
       * Client m�chte auf Serverseite eine Datei lesen. Datei wird on-the-fly komprimiert.
       * Vor der �bertragung Richtung Client werden die Daten im DEFLATE-Format komprimiert.
       * Nach der �bertagung auf der Clientseite dekomprimiert.
       * Pfad muss nat�rlich in der Policy-Datei freigegeben sein (mit "read,write,delete").
       * z.B.:
       *  fileName = /usr/share/doc/test/properties/journal.properties
      public byte[] getFileData(String fileName) {
        System.out.println("read : "+fileName);
        try {
          // Daten laden und gleichzeitig zippen
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          DeflaterOutputStream zipOut = new DeflaterOutputStream(out);
          File f=new File(fileName);
          BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
          int read = 0;
          int len = 0;
          byte data[] = new byte[8192];
          while ((read = in.read(data,0,8192)) != -1) {
            zipOut.write(data,0,read);
            len += read;
          in.close();
          zipOut.close();
          System.out.println("compress-factor : "+len+" to "+out.size()+" bytes");
          return out.toByteArray();
        } catch (Exception e) {
          System.err.println(e);
          return null;
    File : Server.java
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.lang.Thread;
    import java.rmi.*;
    import java.rmi.server.*;
    public class Server {
      static String hostName = "localhost";
      private static int hostPort = 1099;
      static ServerImpl rmi;
      public void startHandler() {
        // RMI starten
        String s;
        try {
          if (hostPort!=java.rmi.registry.Registry.REGISTRY_PORT)         // -> es wurde ein anderer Port gew�hlt
            hostName += ":"+hostPort;
          rmi = new ServerImpl("//"+hostName);
          s = "Bindings Finished. My hostname is : "+hostName;
          System.out.println(s);
          s = "Waiting for Client requests on port "+hostPort+" ...";
          System.out.println(s);
        } catch (java.rmi.UnknownHostException uhe) {
          s = "The host computer name you have specified, "+hostName+" does not match your real computer name.";
          System.out.println(s);
          System.exit(1);
        } catch (java.rmi.RemoteException re) {
          s = "Error starting service :"+re;
          System.out.println(s);
          System.exit(1);
      public static void main(String[] args) {
        System.out.println("Server starting ...");
        Server serv = new Server();
        serv.startHandler();
    File : ClientImpl.java
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    import java.net.*;
    import java.io.*;
    import java.util.zip.*;
    * @author Uwe G�nther
    * @version 20.10.00
    public class ClientImpl {
      private String rmiName = null;
      private IServerImpl js;
      /** Verbingung zum Server aufbauen */
      public ClientImpl(String host,int port) throws RemoteException {
        rmiName = "//"+host;
        if (port!=1099) rmiName += ":"+port;
        rmiName += "/Server_instance";
        try {
          js = (IServerImpl)Naming.lookup(rmiName);
          return;
        } catch (Exception e) {
          e.printStackTrace();
       * Datei auf Serversteite lesen.
       * Datenstrom ist gezippt und wird hier auch wieder entzippt.
      public InputStream getFileData(String pathFile) {
        while(true) {
          try {
            ByteArrayInputStream zipIn = new ByteArrayInputStream(js.getFileData(pathFile));// Datei laden
            return new InflaterInputStream(zipIn);            // Daten entzippen
          } catch(NullPointerException e) {
            return null;                                      // Datei konnte nicht ge�ffnet werden
          } catch(Exception e) {
            System.out.println(e);
            return null;
    File : Client.java
    import java.io.*;
    import java.net.*;
    public class Client {
      private String hostName = "localhost";
      private int hostPort = 1099;
      private ClientImpl rmi;
      public Client() {
        System.out.println("hostname :"+hostName);
        try {
          rmi = new ClientImpl(hostName,hostPort);                        // start RMI
        } catch(Exception e) {
          e.printStackTrace();
          System.exit(1);
        System.out.println("RMI connection successful");
      public static void main(String[] args) {
        Client client = new Client();
        InputStream in = client.rmi.getFileData("text.txt");
        if (in==null) {
          System.out.println("file not found !");
        } else {
          BufferedReader inBuffered = new BufferedReader(new InputStreamReader(in));
          try {
            while (true) {
              String line = inBuffered.readLine();                        // Get next line
              if (line==null) break;
              System.out.println(line);
          } catch(Exception e) {
            e.printStackTrace();
    }Uwe G�nther

  • Listing files from a lan node

    Hello,
    I have an application where I need to look up the file list on a remote meachine connected to my lan network. the java.io.File permit me to look up only the local machine.
    Any tips will be of great help.
    thanks
    shajy mathew

    Hi,
    It is very much possible therough RMI. Here is a sample code which creates a RMI file server.
    RMI Example Architecture
    To demonstrate the java.rmi package, we will create a (very simple) file server. This
    server accepts requests from a remote caller and returns a RemoteObject that is used
    by wrapper classes to provide java.io.InputStream and java.io.OutputStream
    objects that read or write from the remote file.
    The RemoteInputHandle Interface
    First off, we define the interface with which our input wrapper class interacts with
    the remote file (see Listing 54.1). The RemoteInputHandle class provides methods that
    correspond to those required by the java.io.InputStream abstract class. The interface
    simply defines the methods required for an InputStream object. Each method can
    throw a RemoteException as noted in the throws clause.
    Listing 54.1. The RemoteInputHandle interface.
    import java.rmi.*;
    import java.io.IOException;
    public interface RemoteInputHandle
    extends Remote
    public int available( )
    throws IOException, RemoteException;
    public void close( )
    throws IOException, RemoteException;
    public void mark( int readlimit )
    throws RemoteException;
    public boolean markSupported( )
    throws RemoteException;
    public int read( )
    throws IOException, RemoteException;
    public int read( byte b[] )
    throws IOException, RemoteException;
    public int read( byte b[], int off, int len )
    throws IOException, RemoteException;
    public void reset( )
    throws IOException, RemoteException;
    public long skip( long n )
    throws IOException, RemoteException;
    The RemoteInputHandleImpl Class
    Next up is the RemoteInputHandleImpl class, which provides the implementation for
    the RemoteInputHandle interface just defined (see Listing 54.2). The
    RemoteFileServerImpl class creates a new input handle implementation when a
    RemoteInputHandle is requested. The constructor for the implementation class takes
    one argument: the InputStream for which we are providing remote access. This makes
    the handle more useful because we can provide remote access to any local object that
    extends InputStream. This stream is saved in an instance variable (inStream) after the
    UnicastRemoteServer superclass's constructor is called. The superclass constructor is
    called because it has to set things up to listen for requests from remote clients.
    Listing 54.2. The RemoteInputHandleImpl class.
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RMISecurityManager;
    public class RemoteInputHandleImpl
    extends UnicastRemoteObject
    implements RemoteInputHandle
    private InputStream inStream;
    public RemoteInputHandleImpl( InputStream in )
    throws RemoteException
    super( );
    inStream = in;
    Next comes the actual code implementing the methods of the RemoteInputHandle
    interface (see Listing 54.3). Each method simply calls the corresponding method on
    inStream and returns the return value from that call (as appropriate). The RMI system
    takes care of returning the result--as well as any exceptions that occur--to the
    calling object on the remote machine.
    Listing 54.3. The methods of the RemoteInputHandleImpl class.
    public int available( )
    throws IOException, RemoteException
    return inStream.available();
    public void close( )
    throws IOException, RemoteException
    inStream.close( );
    public synchronized void mark( int readlimit )
    throws RemoteException
    inStream.mark( readlimit );
    public boolean markSupported( )
    throws RemoteException
    return inStream.markSupported( );
    public int read( )
    throws IOException, RemoteException
    return inStream.read( );
    public int read( byte b[] )
    throws IOException, RemoteException
    return inStream.read( b );
    public int read( byte b[], int off, int len )
    throws IOException, RemoteException
    return inStream.read( b, off, len );
    public synchronized void reset( )
    throws IOException, RemoteException
    inStream.reset( );
    public long skip( long n )
    throws IOException, RemoteException
    return inStream.skip( n );
    The RemoteInputStream Class
    The RemoteInputStream class extends the abstract InputStream class and uses the
    RemoteInputHandle interface. The constructor first contacts a RemoteFileServer to
    obtain a RemoteInputHandle reference for the path given and then stores this handle
    in an instance variable. The InputStream methods are mapped into the corresponding
    calls on the RemoteInputHandle (that is, the RemoteInputStream read() method calls
    the read() method on the RemoteInputHandle reference obtained by the constructor).
    NOTE: You may wonder why we are using a wrapper class when all it
    does is turn around and call the same method on the interface. The
    reason is that we want to provide a class that can be used any place an
    InputStream or OutputStream can be used. Although this approach
    increases the overhead because we have to make an extra method call,
    the ability to use our remote streams as drop-in replacements outweighs
    the cost of that extra call.
    For example, you can create a PrintStream using a RemoteOutputStream
    for a log file for an application. Anything you print to this PrintStream is
    written to the log file on the remote machine. Without the wrapper class,
    you would have to individually extend each class to use the
    RemoteInputHandle or RemoteOutputHandle as needed.
    We'll start out with the necessary imports and the class definition (see Listing 54.4).
    We need access to the java.io classes because the RemoteInputStream extends
    InputStream. We also need access to the RMI Naming class so that we can use the
    lookup() method to get a RemoteInputHandle from the server. There are two
    constructors for the class: One takes a path name as the argument and contacts the
    file server residing on the same host, and the other takes a remote host name to
    contact as well.
    Listing 54.4. The RemoteInputStream class.
    import java.io.*;
    import java.rmi.RemoteException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    public class RemoteInputStream
    extends InputStream
    private RemoteInputHandle in;
    public RemoteInputStream( String path )
    throws IOException, RemoteException, NotBoundException
    String url = "rmi://localhost/RFSI";
    RemoteFileServer rfs = (RemoteFileServer) Naming.lookup( url );
    in = rfs.getInStream( path );
    public RemoteInputStream( String path, String host )
    throws IOException, RemoteException, NotBoundException
    String url = "rmi://" + host + "/RFSI";
    RemoteFileServer rfs = (RemoteFileServer) Naming.lookup( url );
    in = rfs.getInStream( path );
    Next, each of the InputStream methods is defined (see Listing 54.5). The code for each
    method tries to call the corresponding method on the handle object. If a
    RemoteException occurs, an IOException is thrown with the message from the
    RemoteException as its message.
    Listing 54.5. The InputStream methods of the RemoteInputStream class.
    public int available( )
    throws IOException
    try {
    return in.available( );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    public void close( )
    throws IOException
    try {
    in.close( );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    public synchronized void mark( int readlimit )
    try {
    in.mark( readlimit );
    } catch( Exception e ) {
    System.err.println(
    "RemoteInputStream::mark: Remote error: " + e );
    public boolean markSupported( ) {
    try {
    return in.markSupported( );
    } catch( RemoteException e ) {
    return false; // Assume mark not supported
    public int read( )
    throws IOException
    try {
    return in.read( );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    public int read( byte b[] )
    throws IOException
    try {
    return in.read( b );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    public int read( byte b[], int off, int len )
    throws IOException
    try {
    return in.read( b, off, len );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    public synchronized void reset( )
    throws IOException
    try {
    in.reset( );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    public long skip( long n )
    throws IOException
    try {
    return in.skip( n );
    } catch( RemoteException e ) {
    throw new IOException( "Remote error: " + e );
    The Output Side
    Because the remote interface, implementation, and the wrapper class for the output
    stream version are, for the most part, identical to those for input stream, they are not
    given here. The methods in the interface correspond to those for
    java.io.OutputStream instead of InputStream, and the RemoteOutputStream object
    extends OutputStream. The complete code for all the output classes is contained on
    the CD-ROM that accompanies this book.
    The RemoteFileServer Interface and the RemoteFileServerImpl Class
    The RemoteFileServer interface provides two methods that the remote input and
    output stream classes use to obtain handles (see Listing 54.6).
    Listing 54.6. The RemoteFileServer interface.
    public interface RemoteFileServer
    extends java.rmi.Remote
    public RemoteOutputHandle getOutStream( String path )
    throws java.rmi.RemoteException;
    public RemoteInputHandle getInStream( String path )
    throws java.rmi.RemoteException;
    The server itself is very simple. It consists of a constructor that calls the
    UnicastRemoteServer superclass, a method that does some sanity checking on the
    path names requested, implementations of the interface methods, and a main()
    method that allows the server to be started (see Listing 54.7). We start off as usual
    with the import statements, class declaration, and the constructor. Note that there is a
    static class variable PATH_SEPARATOR, which should be changed to whatever character
    separates directory components on your operating system.
    Listing 54.7. The RemoteFileServerImpl class.
    import java.io.*;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteServer;
    import java.rmi.server.StubSecurityManager;
    public class RemoteFileServerImpl
    extends UnicastRemoteServer
    implements RemoteFileServer
    // Path component separator. Change as apropriate to your OS.
    public static char PATH_SEPARATOR = '/';
    public RemoteFileServerImpl( )
    throws RemoteException
    super( ); // Call superclass' constructor
    // No class specific initialisation needed.
    The checkPathName() method shown in Listing 54.8 does some rudimentary checking
    to ensure that the path name does not point outside the current directory or one of its
    subdirectories. The code that checks for an absolute path (that is, a path that starts at
    the root directory or with a specific drive) should be edited as appropriate for your
    platform.
    Listing 54.8. The RemoteFileServerImpl.checkPathName() method.
    public boolean checkPathName( String path )
    // No absolute path names (i.e. ones beginning with a slash or drive)
    // UNIX Version
    if( path.charAt( 0 ) == PATH_SEPARATOR ) {
    return false;
    // Wintel Version
    if( path.charAt( 1 ) == ':' && path.charAt( 2 ) == PATH_SEPARATOR ) {
    return false;
    // No references to parent directory with ".."
    for( int i = 0; i < path.length() - 1; i++ ) {
    if( path.charAt( i ) == '.'
    && path.charAt( i + 1 ) == '.' ) {
    return false;
    return true; // Path's OK
    Next comes the code implementing the methods of our remote interface (see Listing
    54.9). Each calls checkPathName() on the path and then tries to open either a
    FileInputStream or FileOutputStream as appropriate. Any exception that occurs while
    obtaining a stream is rethrown as a RemoteException (although there is no reason the
    interface cannot throw the appropriate exceptions). Once the stream has been opened,
    a RemoteInputHandleImpl or RemoteOutputHandleImpl object is created as appropriate
    with the just-opened stream. The handle is then returned to the caller.
    Listing 54.9. The methods of the RemoteFileServerImpl class.
    public RemoteInputHandle getInStream( String path )
    throws java.rmi.RemoteException
    FileInputStream file = null; // Used to hold file for input
    // Log that we're opening a stream
    System.err.println( "RFSI::getInStream( \"" + path + "\" )" );
    // Check that the path name is legal or gripe
    if( !checkPathName( path ) ) {
    RemoteException e =
    new RemoteException( "Invalid pathname '" + path + "'." );
    throw e;
    // Try and open a FileInputStream for the path
    try {
    file = new FileInputStream( path );
    } catch( FileNotFoundException e ) {
    // File doesn't exist, so throw remote exception with that message
    RemoteException r =
    new RemoteException( "File does not exist: "
    + e.getMessage() );
    throw r;
    } catch( IOException e ) {
    // Problem opening file, so throw exception saying that
    RemoteException r =
    new RemoteException( "Error opening file: "
    + e.getMessage() );
    throw r;
    // Return value is a RemoteInputHandle for an RIH implementation
    // object created with the file we just opened as it's input stream.
    RemoteInputHandle retval =
    new RemoteInputHandleImpl( file );
    return retval; // Return handle to caller
    public RemoteOutputHandle getOutStream( String path )
    throws java.rmi.RemoteException
    FileOutputStream file = null; // Used to hold file for output
    // Log that we're opening a stream
    System.err.println( "RFSI::getOutStream( \"" + path + "\" )" );
    // Check that the path name is legal or gripe
    if( !checkPathName( path ) ) {
    RemoteException e =
    new RemoteException( "Invalid pathname '" + path + "'." );
    throw e;
    // Try and open FileOutputStream for the path
    try {
    file = new FileOutputStream( path );
    } catch( IOException e ) {
    // Problem opening file for output, so throw exception saying so
    RemoteException r =
    new RemoteException( "Error opening file: "
    + e.getMessage() );
    throw r;
    // Return value is a RemoteOutputHandle for an ROH implementation
    // object created with the file just opened as it's output stream
    RemoteOutputHandle retval = new RemoteOutputHandleImpl( file );
    return retval; // Return the handle
    Finally, we come to the main() method, which can be used to start a standalone server
    from the command line (see Listing 54.10). The first thing this method does is to
    create a StubSecurityManager--a SecurityManager context appropriate for a
    standalone remote object server. Next, main() creates a RemoteFileServerImpl object
    and binds it to the name RFSI. If an exception occurs during object creation or binding,
    the name of the exception is noted and the server exits.
    Listing 54.10. The RemoteFileServerImpl.main() method.
    public static void main( String args[] )
    // Create and install stub security manager
    System.setSecurityManager( new StubSecurityManager( ) );
    try {
    System.err.println( "RFSI::main: creating RFSI." );
    // Create a new server implementation object
    RemoteFileServerImpl i = new RemoteFileServerImpl( );
    // Bind our server object to a name so clients may contact us.
    /* The URL will be "rmi://host/RFSI", with host replaced with */
    // the name of the host we're running on.
    String name = "RFSI";
    System.err.println( "RFSI::main: binding to name: " + name );
    Naming.rebind( name, i );
    } catch( Exception e ) {
    // Problem creating server. Log exception and die.
    System.err.println( "Exception creating server: "
    + e + "\n" );
    e.printStackTrace( System.err );
    System.exit( 1 );
    The rfsClient Class
    To demonstrate how to use our remote files, we now develop a very simple client that
    opens a remote output file and writes a message to it (see Listing 54.11). An input
    stream is obtained and the stream's contents are read back. The output filename is
    defined as outputfile and the input filename defaults to inputfile (however, if an
    argument is given on the command line, that name is used instead). The host
    contacted is defined as the local host, but you can change the URL used to point to a
    remote machine if you have access to more than one host.
    Listing 54.11. The rfsClient class.
    import java.io.*;
    import java.rmi.*;
    public class rfsClient
    public static void main( String args[] ) {
    System.setSecurityManager( new java.rmi.RMISecurityManager() );
    // Contact remote file server running on same machine
    String url = "rmi://localhost/";
    // Default name of file to read
    String infile = "inputfile";
    // Try and open an output stream to a file called "outputfile"
    try {
    OutputStream out = new RemoteOutputStream( "outputfile");
    PrintWriter ps = new PrintWriter( out );
    ps.println( "Testing println on remote file." );
    ps.println( new java.util.Date() );
    ps.flush();
    ps.close();
    ps = null;
    out = null;
    } catch( Exception e ) {
    System.err.println( "Error on getOutStream: " + e );
    e.printStackTrace();
    System.exit( 1 );
    // If we were given a command line argument, use that as the
    // input file name
    if( args.length != 0 ) {
    infile = args[ 0 ];
    // Try and open an output stream on a file
    try {
    InputStream in = new RemoteInputStream( infile );
    DataInputStream ds = new DataInputStream( in );
    // Read each line of the file and print it out
    try {
    String line = ds.readLine( );
    while( line != null ) {
    System.err.println( "Read: " + line );
    line = ds.readLine( );
    } catch( EOFException e ) {
    System.err.println( "EOF" );
    } catch( Exception e ) {
    System.err.println( "Error on getInStream: " + e );
    e.printStackTrace( );
    System.exit( 1 );
    System.exit( 0 ); // Exit gracefully
    I hope this will help you.
    Thanks
    Bakrudeen
    Technical Support Engineer
    Sun MicroSystems Inc, India

  • Binary file transfert over socket : data corupted !

    Hi everyone,
    I am trying to transfert binary files over Socket (java.net) and I get corrupted data... I know the data I write in the Socket is ok and I wonder why I don't get it right at the end.
    Does anyone know about it ?

    Ok i have re-written it without the Packet class and it know works...
    I give my code in case someone would be interested.
    ENCODER :
    public class Encoder {
         // the file to send
         private File file;
          * Constructor of the Encoder class
          * @param path the path to the file to send
         public Encoder(String path){
              this.file = new File(path);
              this.encodeFile();
          * This method contains the connection an file tranfert code
         private void encodeFile(){
              try {
                   // opening file reading stream
                   FileInputStream fis = new FileInputStream(this.file);
                   // connection...
                   Socket sock = new Socket("127.0.0.1", 5698);
                   // opening an output stream
                   BufferedOutputStream bos = new BufferedOutputStream(sock.getOutputStream(), 1024);
                   // start time
                   long start = System.currentTimeMillis();
                   // setting up the buffer
                   byte[] buffer = new byte[1024];
                   /* ---- File Transfert Loop ---- */
                   // reading for the first time
                   int read = fis.read(buffer);
                   while (read > 0){
                        bos.write(buffer);
                        bos.flush();
                        read = fis.read(buffer);
                   /* ----End Of File Transfert ---- */
                   // end time
                   long end = System.currentTimeMillis();
                   // closing streams and connection
                   fis.close();
                   bos.close();
                   sock.close();
                   // display file transfert duration
                   System.out.println("Completed in :" + (end - start) + " ms !");
              } catch (IOException e) {
                   e.printStackTrace();
    DECODER :
    public class Decoder {
         private File destFile;
         public Decoder(String path){
              try {
                   // setting up destination file
                   this.destFile = new File(path);
                   // setting up file writting stream
                   FileOutputStream fos = new FileOutputStream(this.destFile);
                   // setting up connection server
                   ServerSocket serv = new ServerSocket(5698);
                   // accepting client connection request
                   Socket sock = serv.accept();
                   // setting up reading stream for the connection
                   BufferedInputStream bis = new BufferedInputStream(sock.getInputStream());
                   // setting up byte buffer
                   byte[] buffer = new byte[1024];
                   // first reading
                   int read = bis.read(buffer);
                   while (read != -1){
                        // writting buffer content into file
                        for (int i=0; i < read; i++){
                             fos.write(buffer);
                        // reading next bytes
                        read = bis.read(buffer);
                   //closing streams
                   fos.close();
                   bis.close();
              } catch (IOException e) {
                   e.printStackTrace();

  • How to improve custom protocol speed?

    Hi
    I used RMI to get an array of shorts from server.
    Then I thought that using RMI for transferring arrays of primitives
    is not a good idea, that is why I decided to create my own protocol for
    transferring data.
    The other goal to implement my own protocol was to show a data
    transferring progress to user.
    I thought it was not easy to do it with RMI If I am wrong let me know
    how to do it with RMI please :)
    Unfortunately my protocol implementation works slower than RMI.
    Here goes code for simplified version of my protocol.
    Can anyone suggest what I should do to make it work faster.
    Protocol is designed to transfer data provided by FooData from
    FooDTPServer to every connected FooDTPClient.
    The protocol works as follows:
    FooDTPClient connects to FooDTPServer and sends code that indicates
    that it is a client(all codes are described at DTPCodes).
    Server replies with code that indicate that it is FooDTPServer.
    Client asks server for data.
    Server sends a length of data it is going to send and then sends the
    data.
    If client wants more data it sends new request for data.
    If it wants to close connection, it sends special code.
    If client sends wrong code at any state of conversation with server
    the server closes connection.
    Here goes implementation of protocol.
    // file DTPCodes.java
    public class DTPCodes {
    * client sends it to server to at the begin of conversation.
    public static final byte HELLO_IM_DTP_CLIENT = 1;
    * server sends this code as a replay to client
    * HELLO_IM_DTP_CLIENT code.
    public static final byte HELLO_IM_DTP_SERVER = 2;
    * client request for data must start with this code.
    public static final byte GIVE_ME_DATA = 3;
    * client sends this message when he goes away.
    public static final byte BYE = 5;
    // file FooData.java
    /**Simple data provider */
    public class FooData {
    /** Data that FooDTPServer sends to client */
    public static final short[] DATA = new short[1024*768];
    // file FooDTPServer.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    /**FooDTPServer is a simple multithreaded server that sends data */
    public class FooDTPServer {
    public static final int DEFAULT_PORT = 4567;
    /**Contains all running DTPServerThreades*/
    private Set serverThreadsSet = new HashSet();
    /**this flag indicates is server listening or not */
    private boolean listening = false;
    /**port on wich server will accept connection*/
    private int port;
    * Creates instance of FooDTPServer that will run on given port
    * @param port - port on which you what server to listen
    public FooDTPServer(int port) {
    this.port = port;
    * starts server
    * @throws IOException
    * @throws IllegalStateException if server is already running
    public void start() throws IOException, IllegalStateException,
    IllegalArgumentException {
    if (listening == true)
    throw new IllegalStateException("Server already running");
    ServerSocket serverSocket = new ServerSocket(port);
    listening = true;
    while (listening) {
    DTPServerThread t = new
    DTPServerThread(serverSocket.accept());
    t.start();
    serverThreadsSet.add(t);
    serverSocket.close();
    * Stops server
    public void stop() {
    listening = false;
    serverThreadsSet.iterator();
    Iterator iter = serverThreadsSet.iterator();
    while (iter.hasNext()) {
    DTPServerThread t = (DTPServerThread) iter.next();
    if (t.isServing()) {
    t.stopServing();
    * Starts server on default port
    public static void main(String[] args) throws Exception {
    System.out.print("Starting server on port " + DEFAULT_PORT +
    "... \t");
    FooDTPServer fooDTPServer = new FooDTPServer(DEFAULT_PORT);
    System.out.println("Server has started.");
    fooDTPServer.start();
    /** Thead that represent connection with paricular client reqest
    private class DTPServerThread extends Thread {
    /**This flags thread to continue running. */
    private boolean continueServing;
    /**Socket with client */
    private Socket socket;
    /** Creates instance of DTPServerThread.
    * @param socket - socket with client
    * @throws IllegalArgumentException
    public DTPServerThread(Socket socket) throws
    IllegalArgumentException {
    this.socket = socket;
    continueServing = true;
    /**Stops this thread*/
    public void stopServing() throws IllegalStateException {
    if (!continueServing)
    throw new IllegalStateException("Server already
    stoped");
    continueServing = false;
    * @return true if thread is running
    public boolean isServing() {
    return continueServing;
    public void run() {
    try {
    BufferedOutputStream bos = new
    BufferedOutputStream(socket.
    getOutputStream(), 1024 * 768);
    DataOutputStream dos = new DataOutputStream(bos);
    BufferedInputStream bis = new
    BufferedInputStream(socket.
    getInputStream());
    DataInputStream dis = new DataInputStream(bis);
    //check if this is FooDTPClient connected
    if (dis.readByte() == DTPCodes.HELLO_IM_DTP_CLIENT) {
    //write respone to indicate that this is
    FooDTPServer
    dos.writeByte(DTPCodes.HELLO_IM_DTP_SERVER);
    dos.flush();
    while (continueServing) {
    //if cliens requests data
    if (dis.readByte() == DTPCodes.GIVE_ME_DATA) {
    short[] data = FooData.DATA;
    //send him the abount of data you are
    going to send
    dos.writeInt(data.length);
    // then send data
    for (int i = 0; i < data.length; i++) {
    dos.writeShort(data);
    dos.flush();
    else {
    //if client doesn't want more data
    break;
    dos.flush();
    dos.close();
    bos.close();
    bis.close();
    dis.close();
    socket.close();
    catch (IOException ioex) {
    ioex.printStackTrace();
    continueServing = false;
    serverThreadsSet.remove(this);
    //file FooDTPClient.java
    import java.io.*;
    import java.net.*;
    /**Instances of this class interracte with server*/
    public class FooDTPClient {
    private boolean connected = false;
    /**Socket with server */
    private Socket socket;
    private BufferedInputStream bis;
    private DataInputStream dis;
    private BufferedOutputStream bos;
    private DataOutputStream dos;
    private String serverAddress;
    private int port;
    * Creates instance with specified server address and port
    * @param serverAddress - server address
    * @param port - server port;
    * @throws IllegalArgumentException if serverAddress==null or port
    <=0
    public FooDTPClient(String serverAddress, int port) throws
    IllegalArgumentException {
    if (serverAddress == null)
    throw new IllegalArgumentException("serverAddress is
    null");
    this.serverAddress = serverAddress;
    if (port <= 0)
    throw new IllegalArgumentException("port = " + port + " <=
    0");
    this.port = port;
    public void connect() throws IOException, IllegalStateException {
    if (connected)
    throw new IllegalStateException(
    "This instance of DTPClient already connected to
    server.");
    socket = new Socket(serverAddress, port);
    bis = new BufferedInputStream(socket.getInputStream(),
    1024*768);
    dis = new DataInputStream(bis);
    bos = new BufferedOutputStream(socket.getOutputStream());
    dos = new DataOutputStream(bos);
    dos.writeByte(DTPCodes.HELLO_IM_DTP_CLIENT);
    dos.flush();
    byte serverReply = dis.readByte();
    if (serverReply != DTPCodes.HELLO_IM_DTP_SERVER) {
    throw new IllegalStateException("Server gave wrong
    reply");
    connected = true;
    public synchronized short[] getData() throws IOException,
    IllegalStateException {
    if (!connected) {
    throw new IllegalStateException(
    "DTPClient not connected to server");
    dos.writeByte(DTPCodes.GIVE_ME_DATA);
    dos.flush();
    short[] data = new short[dis.readInt()];
    for (int i = 0; i < data.length; i++) {
    data = dis.readShort();
    return data;
    public synchronized void closeConnection() throws
    IllegalStateException,
    IOException {
    if (!connected) {
    throw new IllegalStateException(
    "DTPClient is not connected to server");
    dos.writeByte(DTPCodes.BYE);
    dos.flush();
    dos.close();
    bis.close();
    dis.close();
    bis.close();
    if (socket.isConnected()) {
    socket.close();
    connected = false;
    public synchronized boolean isConnected() {
    return connected;
    public static void main(String[] args) throws Exception {
    int numberOfTries = 100;
    long totalTime = 0;
    FooDTPClient fooDTPClient = new FooDTPClient("localhost",
    FooDTPServer.DEFAULT_PORT);
    fooDTPClient.connect();
    for (int i = 0; i < numberOfTries; i++) {
    long beginTime = System.currentTimeMillis();
    short[] sa = fooDTPClient.getData();
    long operationTime = System.currentTimeMillis() -
    beginTime;
    totalTime += operationTime;
    // System.out.println("Operation N" + i + " took\t" +
    operationTime);
    fooDTPClient.closeConnection();
    System.out.println("Average test time is\t" +
    (totalTime / numberOfTries));
    And here goes server and client that transfer data over RMI
    //file FooRemote.java
    import java.rmi.*;
    public interface FooRemote extends Remote {
    public short[] getData() throws RemoteException;
    //file FooRemoteImpl.java
    import java.rmi.*;
    public class FooRemoteImpl implements FooRemote{
    public short[] getData() throws RemoteException{
    return FooData.DATA;
    //file FooRMIServerRunner.java
    import java.rmi.server.*;
    import java.rmi.*;
    public class FooRMIServerRunner {
    public static void main(String[] args)throws Exception {
    java.rmi.registry.LocateRegistry.createRegistry(5000);
    FooRemoteImpl fooRemote = new FooRemoteImpl();
    RemoteStub fooRemoteStub =
    UnicastRemoteObject.exportObject(fooRemote);
    Naming.bind("rmi://localhost:5000/FooService", fooRemoteStub);
    // file FooRMIClient.java
    import java.rmi.*;
    import java.net.*;
    public class FooRMIClient {
    FooRemote fooRemote;
    public FooRMIClient() throws RemoteException,
    MalformedURLException,
    NotBoundException {
    fooRemote = (FooRemote) Naming.lookup(
    "rmi://localhost:5000/FooService");
    public short[] getData()throws RemoteException{
    return fooRemote.getData();
    public static void main(String[] args)throws Exception {
    int numberOfTries = 100;
    long totalTime = 0;
    FooRMIClient fooRMIClient = new FooRMIClient();
    for (int i = 0; i < numberOfTries; i++) {
    long beginTime = System.currentTimeMillis();
    short[] sa = fooRMIClient.getData();
    long operationTime = System.currentTimeMillis()-beginTime;
    totalTime+=operationTime;
    // System.out.println("Operation N"+i+" took\t" +
    operationTime);
    System.out.println("Average test time is\t" +(totalTime /
    numberOfTries));
    Any help is appreciated.
    Best regards,
    Vitaliy.

    A lot to quote up there, but as for moving away from RMI, since you have the code and in my personal estimation there's really not THAT much overhead for non-remote return types, is there a reason you wish NOT to stay with RMI for this if you have that ability?
    I would however suggest also GZIPping the short[] array and other data as that will save on xfer time, either in RMI or your own personal protocol.

  • How to clear ClassNot found Exception

    Hi
    I am running a simple RMI program in linux. It will give class not found exception.(could not find class(Hello_stub) at code base() )
    1.HelloInterface.java( Remote Interface)
    2.Hello.java(Remote Object Implementation)
    3.HelloClient.java(Client program that invokesa method of the remote interface)
    Steps are followed.
    1.compilation can be done successfully.
    javac HelloInterface.java Hello.java HelloClient.java
    2.run the rmiregistry command. this step also successfully done.
    rmiregistry &
    3.rmic Hello
    this step also done suceessfully.
    this step was create a stub and skeleton classes in the current folder
    All the java codes and the class files are there in a single folder.
    /home/manohar/
    4.Then next step is to run the server program. Here i got an exception ;
    java Hello &
    Exception in SERVER undeclared Checked Exception: nested exception is:
    java.lang.ClassNotFoundException: could not find(Hello_stub) class at codebase().
    This RMI example program run in the windows.
    I am a fresher and new to RMI.If any one knows please help me.
    Thanks and Regards
    Manohar.M

    You either need to have the stub and interface files available in the classpath of the client and server, OR, you need to tell the server JVM to tell the client where it can find RMI files not in the client classpath:
    -Djava.rmi.server.codebase="file:///jars/shared.jar"

  • Applets and EJBs

    Hi:
    we have a jDK 1.1.8 version Applet that needs direct access to a EJB 1.1 version ( Direct access i mean: No servlet in Between applet and EJB). The tool we are using to deploy the EJB to the Applicaton Server 3.6 ( Sybase) is PowerJ 3.6.1.
    The Problem is the applet can access the EJB whenever we run the applet through Appletviewer BUT we get an Intial Context Failure error and subsequently everything related with the Bean functionality fails, when applet is run through a browser ( IE version 5.0 / 5.5 / 6.0)
    Note: The applet's webserver and the Application server are on the same machine.
    Can anyone help on this case.
    Thank you.
    Satish

    Hi paul:
    Thanks for your reply.
    For ur question about using Applest.getCodeBase to construct the URL that you are using for your context provider,
    We use the PowerJ tool to add the intial context and home interface of the EJB to the Applet application.
    I am in a way restricted with this tool. The applet has been developed through this tool and the tool doesnot allow any manual changes to the Intial Context code and the Codebase that it generates.
    I was going through many other forums , some say that Microsoft's ( IE / JVM ) doesnot support rmi stuff.
    Do u think i should make sure that the applet has the rmi files in its classpath because when i look at the stacktrace of the applet , it gives
    root execption: java.rmi.naming.* not found and subsequently Initial context fails.

  • How to send files like audio,video,images and text via RMI..

    Hi everyone,
    As I am working under a project, my own, of creating a chat machine, I've thought to make it capable of doing everything that MSN or yahoo MSN can do. Till now I've just been able to send messages and some small icons as expressions. So, my next step will be making my progam able to send even other files like audio, video, images and text to the person on the other machine to whom I'm chatting. But as I don't have any idea on how to start doing it, I want anyone who think he/she can help me to give me the basic logic that is used to do so. I would very much appreciate it. I've used vectors to store the text messages which is visible to all the users using the chat program enabling them to see various messages in it.
    thank you...
    Jay

    Hi,
    Now, I got stuck because the code doesn't seem to work well. For large files with around 40 mb or more size couldn't be sent. I have constructed the code, just rough sketch, as follows:
    ** In the Server Implementation class I've used FileInputStream to read the contents of a file that is sent as an argument to the method.
    ** Similarly, in the client side I've used RandomAccessFile to save the received array of bytes.
    public void sendFile(File f)
       ChatServer cs=(ChatServer)Naming.lookup("rmi://localhost/ChatServer");
       cs.readsAndStoreTheFileInTheServer(f); // In the Server Implementation the contents of the file is read and saved in an array of byte. later method is invoked by the client to get the array of the saved byte.
       cs.message("-Accept-"); // When a client receives this word then a JComponent with accept and cancel button will be constructed from where other clients can save/cancel the sent file.
    }For small size files this code works well but for files more than 40 mb of size it is useless. I wonder if there's any other alternative.
    regards,
    Jay

  • RMI + JDBC + file transference - URGENT!!

    Ol� pessoal tenho uma d�vida a qual tenho que utilizar comandos JDBC de forma remota e tenho que fazer a transfer�ncia de arquivos, algu�m tem id�ia de como fazer isso?
    Entre RMI e sockets achei sockets mais complicado, o problema que RMI n�o � nada simples, algu�m poderia me ajudar?
    Hello people, I have a doubt which I have that to use commands JDBC of remote form and have that to make the transference of archives, somebody has idea of as to make this?
    Between RMI and sockets a think that sockets more complicated, and the problem is RMI is not simple, somebody could help me?

    wanderley.drumond wrote:
    Ol� pessoal tenho uma d�vida a qual tenho que utilizar comandos JDBC de forma remota e tenho que fazer a transfer�ncia de arquivos, algu�m tem id�ia de como fazer isso?
    Entre RMI e sockets achei sockets mais complicado, o problema que RMI n�o � nada simples, algu�m poderia me ajudar?
    Hello people, I have a doubt which I have that to use commands JDBC of remote form and have that to make the transference of archives, somebody has idea of as to make this?
    Between RMI and sockets a think that sockets more complicated, and the problem is RMI is not simple, somebody could help me?Please avoid using the highly irritating word "URGENT!!" in your subject line in future.
    The first question I would ask is where are these files now? Are they in a database? Or are you trying to put them into a database.
    The second question is what is the client? Remote? Web? Internet?
    If the files are going in/out of the database directly then the simplest solution is just straight JDBC. If there is some complication (like the client is web-based) then maybe something else is required.
    I don't see RMI being a solution here. Possibly but I doubt it (on the basis that if the scenario means that the RMI solution was feasible then I would think the direct JDBC solution would also be feasible) . Maybe FTP.
    I think you may need to get some English help or try on a Spanish language forum though. We'll see how it goes but I do find your question difficult to understand, I only get a general drift of what you are saying but as demonstrated by my questions above I don't really get the specifics.

  • Binary file transfer using RMI

    Thanx in advance !!!
    My Query:
    Is there any restriction on the maximum size of a binary file that can be transferred over RMI?
    In an application (and as per the requirements), I am converting the file contents to a byte array on the client machine and transferring using RMI method calls. At the server side, I am reconstructing the file using the same byte array.
    Writing a Java FTP application is out of question.
    So please advise.
    Vikas

    RMI uses TCP/IP so the default should be close to the standard IP limit.

  • Java.lang.StackOverflowError in geting large xml file with RMI

    Hello, Java Gurus.
    I have a java client to get xml data from a server using RMI approach. When the xml data has a certain number of nodes, I got quoteResult.xsl on the client side. What is the actual problem ? is the file too big ? or something is wrong in the java code?
    thanks. dave
    java.lang.StackOverflowError
         at java.io.BufferedInputStream.read1(Compiled Code)
         at java.io.BufferedInputStream.read(Compiled Code)
         at java.io.ObjectInputStream.read(Compiled Code)
         at java.io.DataInputStream.readFully(Compiled Code)
         at java.io.DataInputStream.readUTF(Compiled Code)
         at java.io.DataInputStream.readUTF(Compiled Code)
         at java.io.ObjectInputStream.readUTF(Compiled Code)
         at java.io.ObjectInputStream.readObject(Compiled Code)
         at java.io.ObjectInputStream.inputClassFields(Compiled Code)
         at java.io.ObjectInputStream.defaultReadObject(Compiled Code)
         at java.io.ObjectInputStream.inputObject(Compiled Code)
         at java.io.ObjectInputStream.readObject(Compiled Code)
         at java.io.ObjectInputStream.inputClassFields(Compiled Code)
         at java.io.ObjectInputStream.defaultReadObject(Compiled Code)
         at org.apache.xerces.dom.ChildAndParentNode.readObject(Compiled Code)
         at java.lang.reflect.Method.invoke(Native Method)
         at java.lang.reflect.Method.invoke(Compiled Code)
    so many these lines
    at java.io.ObjectInputStream.readObject(Compiled Code)
         at java.io.ObjectInputStream.inputClassFields(Compiled Code)
         at java.io.ObjectInputStream.defaultReadObject(Compiled Code)
         at java.io.ObjectInputStream.inputObject(Compiled Code)
    at org.apache.xerces.dom.ChildAndParentNode.readObject(Compiled Code)
         at java.lang.reflect.Method.invoke(Native Method)
         at java.lang.reflect.Method.invoke(Compiled Code)
         at java.io.ObjectInputStream.invokeObjectReader(Compiled Code)
    at sun.rmi.server.UnicastRef.unmarshalValue(Compiled Code)
         at sun.rmi.server.UnicastRef.invoke(Compiled Code)
    at InterfaceImpl_Stub.ExportData(Compiled Code)
         at ClientServlet.handleRequest(Compiled Code)
         at ClientServlet.doGet(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled Code)
         at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled Code)
         at org.apache.tomcat.servlets.InvokerServlet.service(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled Code)
         at org.apache.tomcat.core.ContextManager.service(Compiled Code)
         at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Compiled Code)
         at org.apache.tomcat.service.TcpConnectionThread.run(Compiled Code)
         at java.lang.Thread.run(Compiled Code)

    Hi yue42, thanks alot for your rely.
    The error occured before I tried to apply the xsl template to translate the xml data into html page, anyway here is my template. dave
    <?xml version="1.0"?>                                                           
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
    <xsl:output method="html"/>                                                     
    <xsl:include href="global.xsl"/>
    <xsl:template match="/">                                                        
    <html>                                                                          
    <head>News</head>
    <body>
    <table>
    <xsl:for-each select="//NEWS/STORY">
    <xsl:if test="6>position()">
    <tr>
    <td><xsl:value-of select="position()"/></td>
    <td><xsl:value-of select="./HEADLINE"/></td>
    </tr>
    </xsl:if>
    </xsl:for-each>
    </table>
    </body>         
    </html>         
    </xsl:template> 
    </xsl:stylesheet>                                   

Maybe you are looking for

  • Module pool custom fiel ZTEST doesen't memorize value

    hello, i have create a module pool with a custom field ZTEST declared in the TOP include. The same name i have declared in the Dympro '0100'. In the after input i tried to get the value but the variable ZTEST doesen't contains value also if i have fi

  • Stop forcing upgrades

    I have been forced, by repeated interruptions to my work telling me that software had been downloaded, to upgrade Adobe Reader through two steps, first to 9.3.1 then to 9.3.2. This is a pure pain because I do not use Reader, having switched to Previe

  • How to control comments at the bottm of the page

    I have a requirement to print a comment based on the materail type - on a custom print out for Delivery. This comment is to be pritned at the bottom of the page if the particualr material is present. So if the particualr material type is avaialable o

  • Mountain Lion not downloading

    Hi, I have been invoiced as having purchased OSX Mountain Lion but I keep getting an error message when trying to download it from the App Store. It basically gets to around 50MB as downloaded and then says 'The Application could not be downloaded. T

  • Select menu plug-in

    Rick Johnson of Graffix made a wonderful plug-in that expanded the Select menu. It was created for CS3-CS5. With one click, you could select all open or closed paths, filled or unfilled paths, dashed paths, compound paths, clipping masks, guides, ras