This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Well in my Beta I am putting the ConnectionFactory into the Registry, the call to getConnection returns an instance of DataAccess. Inside the code I create a new DataAccessRemote which implements DataAccess. DataAccess interface extends Remote, and DataAccessRemote extends UnicastRemoteObject. So the signature of getConnection is public DataAccess getConnection() throws RemoteException. So in my client when I call getConnection, the object that returns is an instanceof DataAccess and DataAccessRemote_Stub, but NOT DataAccessRemote So when I call a method on the returned object, I get a NullPointerException, but there is an Object returned, otherwise the instanceof wouldn't work. So what am I overlooking? Mark
Hi Mark, Sorry I have'nt been as active as I'd like recently: I have just a smazing amounts of things to do. To pursue your question: I've having a hard time picturing the design: probably a sign of age. Can you go into a bit more detail please? All best, M, author The Sun Certified Java Developer Exam with J2SE 1.4
OK, simply put. I have an interface A that extends Remote. I have an implementing class B that extends UnicastRemoteObject. I have one class that I put into the Registry. The client looksup the class in the Registry, calls a method on that class, that returns the class B. So the client receives class B's Stub, but if you compare that to the interface A and the Sub class with instanceof you get True, but instanceof to class B returns False. So I call a method that is in class B, therefore also in its stub and I get a NullPointerException. It is the only problem I have and makes the remote version of the assignment not work. Thanks Max Mark
Help. I took the essay exam today, but I haven't uploaded the assignment yet, and I think I will only have till the end of today to finish it. This problem is bothering me since it should work, and that means that I did something stupid that I am overlooking. Mark
I'll post as much of the exception trace that win 98 will show in dos window.
It is killing me. Mark
Joined: Jun 18, 2002
Looks like the reference to the DataAccessRemote object on the server side no longer exists. Have you tried making the clientConnection variable a class member of ConnectionFactory instead of a local variable inside getConnection()?
Each client gets their own instance. and that is the exact same code I used in my submission in the actual assignment. Actually all my code in this area is exactly the same as my first submission and this Beta. Mark
town drunk ( and author)
Joined: Jun 27, 2002
Originally posted by Mark Spritzler: OK, simply put. I have an interface A that extends Remote. I have an implementing class B that extends UnicastRemoteObject. I have one class that I put into the Registry. The client looksup the class in the Registry, calls a method on that class, that returns the class B. Mark
Hi Mark, Sorry I couldn't get back to you sooner: I teach a double class on thursdays, after a full day @ the office, so I just got in. I coded the implementation you're describing, and it worked just fine: I even tested it on a remote machine. It's not your design, so this must be an implementation issue. Without actually seeing the code, I can't really help there. All best, M, author The Sun Certified Java Developer Exam with J2SE 1.4