GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:RMI exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:RMI exception" Watch "NX:RMI exception" New topic
Author

NX:RMI exception

guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
when i run client by Remote Mode
i get exception:
java.security.AccessControlException: access denied (java.net.SocketPermission f
enet-steven resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11465
    
  94

Hi Steven
Have you coded a SecurityManager into your application? If so, then you probably want to get rid of it. This error usually occurs when you have a line in your code like:
You do not need (or want) a security manager for any of the assignments, and in the new assignments it is explitly stated that you should not have a security manager.
If that hasnt fixed your problem, then what are you using for hostname and socket number? I suggest you go with "localhost" and the standard socket number to get things working.
By the way, we like to see a last name in the displayed name. This is described in the JavaRanch naming policy. Could you please update your displayed name to show this? You can change it here.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
thanks , now i get rid of the code of
"System.setSecurityManager(new RMISecurityManager());"
but when i run i get new exception like this :
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: suncertify.server.RemoteData_Stub (no
security manager: RMI class loader disabled)
java.lang.ClassNotFoundException: suncertify.server.RemoteData_Stub (no security
manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.inputClassDescriptor(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.inputObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
by the way ,because i put the remote interface named remoteData in the <db> package , and put
the class named remoteDBAccess which implemented
remoteData in the server package.
how can i put the RemoteData_Stub.class into the
client package?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11465
    
  94

Steven
Could you please put a first and last name into your displayed name, as described in the JavaRanch naming policy? You can change it here.
I have put a note in this thread stating that it is a duplicate, and should be closed. If you disagree, please post a comment in that thread stating what the differences are, and why it should stay open.
how can i put the RemoteData_Stub.class into the client package?

All you need to do is ensure that suncertify.server.RemoteData_Stub.class is in the client package (note: the directory structure needs to be there as well).
Try that, and see if your exceptions disapear.
Regards, Andrew
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
thanks first
my question is how can i put the RemoteData_Stub.class into the
client package?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11465
    
  94

Steven
I think I need to clarify what you mean by "client package". When I first read your email, I assumed you were talking about creating a package to distribute to clients. In this reference, I was reading "jar file" instead of "package".
But I realise that I am almost certainly wrong: you are using the term package in the same way that Sun use it: to describe the directory structure for the classes.
So RemoteData (and therefore RemoteData_stub) are in the suncertify.server package, and this is where they belong.
Assuming you have a directory structure like:

Then as long as you start your application with java -cp classes .... the client should be able to find the stub file.
(Change the example directory structure to suit your layout of course).
Likewise, when you package it all into an executable jar file, the client code will be in the same jar as the stub file, so it will be able to find it.
Regards, Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:RMI exception