• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bringing an existing API to Remote Invocation  RSS feed

 
Vijayendra Kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working with an existing API and I do not have its source. The interface is:


I need to build an application so that this API can be used with RMI. What I did is:


When I run rmic on a class that implements RemoteWork, it fails to generate the stub complaining about mismatch Throws between RemoteWork and IWork. Am I doing something wrong? Thanks for your help.

[ December 29, 2008: Message edited by: Vijayendra Kumar ]
[Nitesh: Added code tags. Please UseCodeTags]
[ January 02, 2009: Message edited by: Nitesh Kant ]
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"MeJava Dev" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.

And welcome to Javaranch
 
Vijayendra Kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not see any replies.. so pinging the community again. How is it possible to use an interface that does not extend Remote interface and throws RemoteException in a way that rmic can be used? Is there a pattern that can be used instead?

If I need to use this interface in rmi environment then how to do it? I cannot do

and,

rmic fails on MyRemoteImpl.class.

[Nitesh: Added code tags. Please UseCodeTags]
[ January 02, 2009: Message edited by: Nitesh Kant ]
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its strange that you were able to compile RemoteWork, it will give you a compile time error as you can not override a method in an interface just to add an exception.
This is not an RMI problem.

Why do you need to extend the interface IWork here in RemoteWork?
 
Vijayendra Kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to compile the classes using Ojc (jdeveloper) but it fails with javac but that seems another problem. So, the question is how can I use a non-remote interface in a RMI environment? I do not have source code so as to change the implementation of the root interfaces.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is no, you can't. If the methods of an interface aren't declared to throw some supertype of RemoteException, then it can't be used directly in this way. What you'll have to do instead is create "wrapper" objects. Define a new interface that has similar (or the same) method names, but are declared to throw RemoteException. Use this interface for your servants, which would then look like



Clients would have to use IWorkRemote, not IWork.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!