Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Security Exception

 
Joseph Schulz
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow developers!

Could someone please point me in the right direction? I am getting RMI.Security Exception (see below for full stack) when i try to start Network Client (I should mention that I start Server first with no problem).

Any help would be greatly appreciated!

Excpetion Stack:
---------------
Jul 8, 2006 12:48:20 PM suncertify.gui.GuiController <init>
SEVERE: RemoteException occurred in server thread; nested exception is:
java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract void suncertify.db.DBAccess.unlock(long,long) throws suncertify.db.SecurityException
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract void suncertify.db.DBAccess.unlock(long,long) throws suncertify.db.SecurityException
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at suncertify.server.$Proxy0.getClient(Unknown Source)
at suncertify.server.DatabaseConnector.getRemote(DatabaseConnector.java:40)
at suncertify.gui.GuiController.<init>(GuiController.java:53)
at suncertify.gui.MainWindow.<init>(MainWindow.java:89)
at suncertify.gui.ApplicationRunner.<init>(ApplicationRunner.java:59)
at suncertify.gui.ApplicationRunner.main(ApplicationRunner.java:29)
Caused by: java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract void suncertify.db.DBAccess.unlock(long,long) throws suncertify.db.SecurityException
at sun.rmi.server.UnicastServerRef.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.<init>(Unknown Source)
at java.rmi.server.UnicastRemoteObject.<init>(Unknown Source)
at suncertify.server.DataServer.<init>(DataServer.java:42)
at suncertify.server.DatabaseFactoryImpl.getClient(DatabaseFactoryImpl.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: illegal remote method encountered: public abstract void suncertify.db.DBAccess.unlock(long,long) throws suncertify.db.SecurityException
at sun.rmi.server.Util.checkMethod(Unknown Source)
at sun.rmi.server.Util.getRemoteInterfaces(Unknown Source)
at sun.rmi.server.Util.getRemoteInterfaces(Unknown Source)
at sun.rmi.server.Util.createProxy(Unknown Source)
... 18 more
-------------
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you're attempting to call a method on an abstract class rather than a concrete class, causing RMI to fail in instantiating an instance of that class.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

RMiException warps the real cause for the exception so look for "Caused by:..."

Regards M
 
Joseph Schulz
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for you reply. I think the underlying issue here is that my interface methods do not throw RemoteException which is required by RMI.

Actually my project is based on DVD sample project whereas their extended itnerface methods throw RemoteException but mine do not since I get compiler error (when I try to add RemoteException) that my DBAccess interface methods have different signature type.

Any ideas?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joseph,

Starting with a very generic hint: have you looked at what the Adapter design pattern can do for you? (Here is a a guide to one way of using it).

Regards, Andrew

P.S. dont get caught up on the fact that they are talking about adapting methodA() to methodB(). You have a very similar problem where you are trying to use a particular method signature (which specifies certain throwable exceptions) to another method signature (which doesnt have the same throwable exceptions).
 
Joseph Schulz
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,

Thanks for your reply, I will study it more and try to understand the DVD sample project design better.

J.
 
Joseph Schulz
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew et all,

I figured out the root cause of my problem, took me awhile but work is relentless...

In DVD sample project, all methods in DBClient interface throw IOExceptions ... AND RemoteException extends it (IOException). Try removing or replacing throw IOException in any of the methods of DBClient and the RMI model will not work AND will give you syntax error I was getting.

Andrew, could you shed some light on this please? How would you go about if your DB interface could only be allowed to throw a custom exception that extend regular "Exception"?

Thanks,
J.

[ July 13, 2006: Message edited by: josepek ]
--------------------------------------------
After some thinking I figured out the solution and answered myself the question I directed to Andrew .

If anyone could comment on my solution I would really appreciate it.

1. My db interface for RMI access does not extends DBAccess, it just defines same methods as DBAccess but it adds needed RemoteException to the methods definitions.
(interface DBRemoteAccess extends Remote)
2. My network server database implemntation creates instance of the Data class and then appropriately implements methods of DBRemoteAccess interface
(class DataServer extends UnicastRemoteObject implements DBRemoteAccess)
3. Within the controller for my gui, based on the selected connection type I use appropriate interface, DBAccess or DBRemoteAccess.
[ July 13, 2006: Message edited by: josepek ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "josepek"-

Welcome to JavaRanch.

On your way in you may have missed that we have a JavaRanch Naming Policy for displayed (screen) names. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Since yours, "josepek", does not conform with it, please take a moment to change it, which you can do right here.

Posters with nonconforming displayed names will be locked out of JavaRanch after a few posts using those names.

Thanks
-Barry

(NR) - search tag
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic