• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI - access denied

 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using RMI in Eclipse developing a serer/client aaplication on my PC...

Everything compiles and the WBRemote_Stub.class is generated

How do I fix/prevent this message when starting the server program?

I am new to this so even the most basic ideas will be of help. I am still reading the RMI tutorial which is pretty vague about external things (e.g. policy.file, is this something I need to do??) so any step by step ideas gratefully accepted.

Thanks,
Gary


WBRemote exception: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)

 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to do something to keep your server "alive" after you bind it. The simplest thing to do is just - Thread.sleep( Long.MAX_VALUE ). If you don't do something to prevent the program from exiting once it leaves the main method the reference bound in the RMI registry is "stale".
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nate,
unfortunately the problem is with the rebind itself. The main I included is from the remote/server program. I haven't got to testing the client as yet. I believe i have a problem with the RMI plugin in Eclipse IDE. I have contacted them about that and am waiting for a reply.

Thanks again,
I'll let you know one way or the other,
Gary.
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ALL my class files live in
G:\eclipse\workspace\WordBank\bin\wordbank

My policy file is
G:\eclipse\workspace\WordBank\policyFile

I use the following parameters to run my program
-Djava.rmi.server.codebase="file:/G:/eclipse/workspace/WordBank/bin/wordbank"
-Djava.security.policy="file:/G:/eclipse/workspace/WordBank/policyFile"

The main of my remote :-

I thought I'd give it a try without the security manager and get this:-

What have I missed???


WBRemote: pre rebind //127.0.0.1:1099/WBInterface
WBRemote exception: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: wordbank.WBRemote_Stub
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: wordbank.WBRemote_Stub
at sun.rmi.server.UnicastServerRef.oldDispatch(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)
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 sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at java.rmi.Naming.bind(Unknown Source)
at wordbank.WBRemote.main(WBRemote.java:192)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: wordbank.WBRemote_Stub
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(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.ClassNotFoundException: wordbank.WBRemote_Stub
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 9 more

What have I missed???
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing the initialization properties to this -


I've always had to put three slashes between the "file:" protocol and the path, and the codebase property should point to the wordbank package, not to the classes inside the package.
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nate,
thanks for your efforts so far.

Do the class files need to be in a jar file instead of individual classes in the diectory?

As you see, I'm pretty new to this and seem to have gotten into a hole at the moment.

Thanks again.
Gary.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nathan Pruett:


I've always had to put three slashes between the "file:" protocol and the path, and the codebase property should point to the wordbank package, not to the classes inside the package.


There's a raeson for that, but it's not obvious. Two of the slashes are part of the protocol definition (e.g. "http://"). The third is because the Internet protocols grew up int the Unix world, where there's not a collection of disk drives, but a unitary file structure, whose absolute root is "/". For Unix/linus, thus, /home/timh corresponds to "C:\timh" (dependinging on where you like to start locating from). And the URL would be "file:///home/timh"!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's actually really interesting Tim! I've always wondered why the extra "/" was needed for file: URLs!

Gary,

It's fine for the classes to be in a directory or in a JAR file. The codebase is just like the classpath. Instead of pointing to the directory the class files are in, you point to the root of the package they are in. For un-JARed classes, this means you specify the directory that is directly above the highest package directory. i.e. Your project build directory is in C:\javaprogs\myProject\classes. Your classes are in the package com.mystuff.myproject. This means the class files are actually in the directory C:\javaprogs\myProject\classes\com\mystuff but you don't specify this directory as your codebase (or classpath), you specify where the package starts - C:\javaprogs\myProject\classes
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone,
I now have comunicating clent/server classes.
My problem was basically being pretty new at this stuff and an environmental problem with my "Eclipse" setup.

All the help, comments etc.. are greatly appreciated.

For me, it is on to getting my head around the "Serializable" classes.

Thanks again,
Gary.





 
Rebecca Hopper
Ranch Hand
Posts: 38
Firefox Browser Hibernate IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you fix your problems with your Eclipse setup? I am using WebSphere 5.1, which runs Eclipse, and am getting a SocketPermission error when I run the Client. The application isn't seeing my security.policy file, even though I am using VM Arguments exactly like those shown above, except for the pathnames of course. Is there something else you had set in Eclipse?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic