File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DataAccessRemote Beta 1.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DataAccessRemote Beta 1.4" Watch "DataAccessRemote Beta 1.4" New topic
Author

DataAccessRemote Beta 1.4

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
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


Java Regular Expressions
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
Tybon Wu
Ranch Hand

Joined: Jun 18, 2002
Posts: 84
My guess is that something is wrong with the getConnection() method of ConnectionFactory. Can you post the code for that method?


SCJP2
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6


It is the exact same code I used in my submission over 1 1/2 ago that worked fine.
Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I'll post as much of the exception trace that win 98 will show in dos window.

It is killing me.
Mark
Tybon Wu
Ranch Hand

Joined: Jun 18, 2002
Posts: 84
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()?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataAccessRemote Beta 1.4