• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about ConnectionFactory implementation

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Ranchers:
I will bind ConnectionFactory object to RMI. I already have a remote object called RemoteDataAccess. ConnectionFactory has a method
getConnection to create a remote connection for every client. Here is what bafling me: RemoteDataAccess extends UnicastRemoteObject and implements DataInterface, if I have to create another remote object ConnectionFactory, should I do the same thing like: create a ConnectionInterface which extends Remote, and shared by both server and client like DataInterface, then define ConnectionFactory object to extend UnicastRemoteObject and implement ConnectionInterface?
The following code just give me a strange error message:

LINE A just gives me this strange error message:


unreported exception java.rmi.RemoteException; must be caught or declared to be thrown
public class ConnectionGateway extends UnicastRemoteObject


Any help appreciated.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A couple guesses:
1. The interface needs to extend remote
2. The factory constructor needs to throw Remote Exception
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both remote objects should be implemented the same way. The only difference between them is that the factory object will be bound to the registry, and the code for that is outside of the implementation. So, define an interface for both, make sure it extends Remote, and throw RemoteExceptions on your implementation methods.
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks for your replies, guys. The above is what exactly I did. All interfaces extend Remote, and
all methods throw RemoteExceptions. Still wondering what's hapening....
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your constructor throw Remote exception?
public ConnectionGateway() throws RemoteException{
super();
}
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Robin Underwood:
Does your constructor throw Remote exception?
public ConnectionGateway() throws RemoteException{
super();
}


Thanks Robin, you are right, I missed that one.
Just fixed the problem. I just feel blind sometimes.
reply
    Bookmark Topic Watch Topic
  • New Topic