Hey everyone I’m having a problem passing a variable in RMI. This is for school, so there are some fairly strict requirements that I have to follow. I have a servlet that is the controlling servlet for the app this servlet is to use requestdispatcher to forward requests to the appropriate other servlet for processing. One of the servlets gets a reference form the session to a remote object. This remote object has an instance of another non-remote object as one of its members. The remote object ‘RemoteCustomer’ has a method called setCurrentOrder(DinnerOrder order). The DinnerOrder object is a non-remote object. The RemoteCustomer just takes the passed in DinnerOrder and assigns it to an instance member. I keep getting a java.rmi.UnmarshalException when I call the remote method setCurrentOrder. I have declared the DinnerOrder class to implement serializable. Here is the class definition:
I added the read/writeObject because it didn’t work without them. However, it doesn’t work with them. Id didn’t think I had to do anything with the inner class because it only has primitive and Strings as members so they should serialize just fine. Do I need to specifically serialize each Dinner object in the Vector? I didn’t think so because Vector is serializable itself. Here is the actual Exception as reported in tomcat: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.net.MalformedURLException: no protocol: Files/Apache java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.net.MalformedURLException: no protocol: Files/Apache java.net.MalformedURLException: no protocol: Files/Apache at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122) at RemoteCustomerImpl_Stub.setCurrentOrder(RemoteCustomerImpl_Stub.java:123) at OrderServlet.doPost(OrderServlet.java:49) I don’t understand the MalformedURLException unless that has something o do with the serialization process. Any help would be greatly appreciated. Thanks
Ok, I made some changes and now have different issues. I got rid of the inner class because I read that they can be hard to serialize but now get different errors depending on what method I call. The program has to use a remote class that accesses the database and registers itself with the registry to make itself available, this class also serves as a facotry class. When I try to invoke a remote method from this class on a DinnerOrder object I get the following exception:
But if I call a method on the RemoteCustomer object (passing it the DinnerObject) I get this now - where I used to get the last error I reported:
It think this has something to do with the way I am running this. I have all of the class files in the classes directory of tomcat but I copy the remotely accessabe classes to a folder just off of the root to make it easier to type in the codebase, but also because there are spaces in the tomcat install directory. The reason I think this is an issue is because it is reporting an exception at 'Files\Apache' this is where the first space would be in the path to the class files. I guess the first step is I need to know how to put spaces into the codebase - I tried enclosing it in quotes but that didnt work. Then if anyone else has any other input that'd be great, this is driving me nuts. I really dont want to make the DinnerOrder a remote object - it doesn't need to be and that just makes the code even more confusing. thanks Dave
OK, solved the current poroblem by just unistalling tomcat and reinstalling it to a directory off of c:\ with no spaces. That seems to have fixed the problem so far. Anyone know how to fix it so you can run it from any directory - I'll also ask in apache tomcat but going to leave this here as someone else might be able to use it too.
The knights of nee want a shrubbery. And a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss