Results 1 to 9 of 9
  1. #1
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Error when running a basic server setup

    These three code fragments are from the Javacore vol II book, concerning server stuff (server client)
    While running the code I get the following error, what is going wrong here:

    Binding server implementations to registry...
    Error: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: serverstuff.Product
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: serverstuff.Product
    at sun.rmi.server.UnicastServerRef.oldDispatch(Unicas tServerRef.java:400)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:248)
    at sun.rmi.transport.Transport$1.run(Transport.java:1 59)
    at java.security.AccessController.doPrivileged(Native Method)

    The ClassNotFoundException: serverstuff.Product is weird since the class is present at serverstuff!
    The file is actually an interface..... might that be the problem... I don't think so?




    Java Code:
    package serverstuff;
     
    /**
     * The interface for remote product objects.
     * Gets the description of this product.
     * @return the product description
     * 
     */
    import java.rmi.*;
     
    public interface Product extends Remote {
        String getDescription() throws RemoteException;
    }

    Java Code:
    package serverstuff;
     
    /**
     * This server program instantiates two remote
     * objects, registers them with the naming service,
     * and waits for clients to invoke methods on the
     * remote objects.
     * 
     */
     
     
    /**
     * @version 1.10 1999-08-21
     * @author Cay Horstmann
     */
     
    import java.rmi.*;
    import java.rmi.server.*;
     
     
    public class ProductServer
    {  public static void main(String args[])
       {  try
          {  System.out.println
                ("Constructing server implementations...");
     
             ProductImpl p1
                = new ProductImpl("Blackwell Toaster");
             ProductImpl p2
                = new ProductImpl("ZapXpress Microwave Oven");
     
             System.out.println
                ("Binding server implementations to registry...");
     
             Naming.rebind("toaster", p1);
             Naming.rebind("microwave", p2);
     
             System.out.println
                ("Waiting for invocations from clients...");
          }
          catch(Exception e)
          {  System.out.println("Error: " + e);
             e.printStackTrace();
          }
       }
    }

    Java Code:
    package serverstuff;
     
     
    /**
     * @version 1.00 1996-09-07
     * @author Cay Horstmann
     * This is the implementation class
     * for the remote product
     * Constructs a product implementation
     * @param n the product name
     *
     */
     
    import java.rmi.*;
    import java.rmi.server.*;
     
    public class ProductImpl extends UnicastRemoteObject
                               implements Product {
        public ProductImpl(String n)
           throws RemoteException {
           name = n;
        }
     
       public String getDescription() throws RemoteException {
          return "I am a " + name + ". Buy me!";
       }
     
       private String name;
    }

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,855
    Rep Power
    5

    Default Re: Error when running a basic server setup

    The problem is not the class not existing - the problem is that Java can't find it when running the application. In other words: the class is not on the classpath.

    This is about RMI, so you have a client and a server. Likely the interface is not on the classpath of the client application.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: Error when running a basic server setup

    so what I should be doing, gimbal?
    I started the server to register Under UNIX, use the command:
    java ProductServer &
    Last edited by willemjav; 09-10-2013 at 04:09 PM.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,855
    Rep Power
    5

    Default Re: Error when running a basic server setup

    you cannot be doing RMI stuff and not know how to deal with classpath problems - that's essential core Java knowledge.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: Error when running a basic server setup

    so the interface is at the package serverstuff in a file called Product!
    Is that not the way to declare an interface?
    If not where should it be?

  6. #6
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: Error when running a basic server setup

    Ok. ok "you cannot be doing RMI stuff and not know how to deal with classpath problems"
    I know about classpath etc. but I do have some blacks....
    So what should I be doing?
    Classpath stuff is tricky and nobody really explains it well, right gimbal?
    Several month I studied unix command line stuff and I am aware of the clathpath var etc.
    but not getting the larger picture yet!
    Last edited by willemjav; 09-10-2013 at 04:23 PM.

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,855
    Rep Power
    5

    Default Re: Error when running a basic server setup

    Well then you should get that bigger picture - by re-reading your book on core Java. Until then doing anything as advanced as this is pointless.

    Good luck with this, I'm not going to invest time into someone that did not take the time to properly learn AND understand the basics first.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: Error when running a basic server setup

    gimbal I understand your "attitude". I am turning pages. The previous subject was Datab. and I had no clue how to start and might have gotten a similar remark when asking than. But you know what, I learned the basics of Unix and got mysql going from the command line, I setup the java part (driver etc.) and did some queries in connecting java (JDBC) with mysql. So remote objects is my next subject and here I am!

    I did work, of course, with interfaces but never did one myself. I noticed that in the official RMI manuel the compute engine is in one package and the interfaces (compute and task) in another.

    Ok you gave me an important clue: classpath.... So I'll go for that, thanks gimbal!

    BTW the Java tut example is interesting tough complex and I did this reduction (still grasping the concept):

    can't download image
    Last edited by willemjav; 09-10-2013 at 08:51 PM.

  9. #9
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: Error when running a basic server setup

    Until now I have been programming within the cozy Netbeans environment. Here you hardly run into flags and classpath stuff since Netbeans takes care of it all! For me that was perfect until now, since I could concentrate fully on the java grammar which was already hard enough.
    When I started with Database issues I had to go into command line stuff, of which I understood none. So I learned the basics about Unix.
    Now I understand that it is about time to get familiar with classpath and other issues, which happen under the hood of java and which you usually reach by command line. I do understand the importance of this all and I do not always to study what on what moment!
    I do not have a computer science background and get familiar with things mostly in a unconventional manner. I think there should be more blog members that recognize this, right?
    Last edited by willemjav; 09-10-2013 at 10:33 PM.

Similar Threads

  1. Creating a basic proxy server
    By driiper in forum Networking
    Replies: 2
    Last Post: 04-27-2012, 01:04 AM
  2. Security Concerns with a basic HTTP server
    By coiner in forum Networking
    Replies: 0
    Last Post: 10-05-2011, 10:43 PM
  3. Not able to see apache2 server in Eclipse WTP Setup
    By anupindi007 in forum Eclipse
    Replies: 1
    Last Post: 05-28-2011, 04:57 PM
  4. basic Server Networking
    By altosaxplayer88 in forum Networking
    Replies: 5
    Last Post: 05-23-2011, 02:39 AM
  5. setup oc4j server in eclipse 3.3
    By mamri in forum Eclipse
    Replies: 0
    Last Post: 12-22-2008, 11:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •