Re: Help with java.rmi.server.codebase
"Vanfleet, David" <[email protected]> Tue, 26 Dec 2006 09:07:09 -0800
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <352366D52DA72B4295106E3C65E1719103B1F33E@USCYMPLM004.net.plm.eds.com> |
Oliver, thanks for your comments. I made some changes as you suggested below. I used "==" to specify the policy file and I commented out System.setSecurityManager in my server. Unfortunately, I still get the same java.lang.NoClassDefFoundError error. Any other suggestions? Thanks Again, David -----Original Message----- From: Oliver Ashoff [mailto:[email protected]] Sent: Saturday, December 23, 2006 11:54 AM To: Vanfleet, David; [email protected] Subject: AW: Help with java.rmi.server.codebase I had problems, too. I am not a real expert but my remarks could help, I hope. I had tried to get runnging the RMI example that is given at SUN's www tutorial. Finally, I got it. My bat-File to start the server looks like this: SET CODEBASE=-Djava.rmi.server.codebase=http://localhost:2002/ SET POLICY= -Djava.rmi.server.hostname=localhost -Djava.security.policy==file://C:/<path>/allPermissions.policy SET CP=-classpath ../build java %CODEBASE% %POLICY% %CP% example.hello.Server where <path>=Projects/RmiTutorial/RmiTutorial/bin My policiy file looks like this: grant { permission java.net.SocketPermission "*:1024-65535", "connect,accept"; permission java.io.FilePermission "C:\\Projects\\RmiTutorial\\RmiTutorial\\-", "read"; }; I guess that your version of the policy file grant { permission java.security.AllPermission; }; should also work. A) Note that I have typed "==" instead of "=" specifying the policy file. That is ... -Djava.security.policy==file:// ... There are several policiy files that are read by default. I think the first defintion of a property wins. When you use "==" instead of "=" only your specified policy file is read. My be that is the crucial point!? B) In my class example.hello.Server I commented out //System.setSecurityManager(new RMISecurityManager()); I dont instantiate a new RMISecurityManager. At least not explicitly. The server code looks as follows: Registry registry = null; try { registry = LocateRegistry.createRegistry(1099); // 1099 is default. Should work without the argument 1099. } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); } try { Server obj = new Server(); Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0); Naming.rebind("Hello", stub); System.err.println("Server ready"); } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); } Hope that helps. Regards, Oliver -----Ursprüngliche Nachricht----- Von: Vanfleet, David [mailto:[email protected]] Gesendet: Samstag, 23. Dezember 2006 18:46 An: [email protected] Betreff: Re: Help with java.rmi.server.codebase Here's an update: I added -Djava.security.debug="access" to the starup script and tried to restart the server. When I did this I got the following message: access denied (java.lang.RuntimePermission createSecurityManager) I then changed my security policy to: grant { permission java.security.AllPermission; }; When I again tried to restart the server I got a bunch of "access allowed" messages, then I got the same NoClassDefFoundError shown below. This leads me to believe that my security manager is setup correctly but the problem is with the implementation of my codebase property. Thanks, David -----Original Message----- From: Vanfleet, David [mailto:[email protected]] Sent: Saturday, December 23, 2006 9:18 AM To: [email protected] Subject: Help with java.rmi.server.codebase I'm trying to setup my RMI server so it can load some if the needed classes off an http server rather than having to put them on the local system. Please note that I'm not interested in having the client load these remote classes, only the RMI server. The script that's starting this server looks like: #!/bin/sh export CLASSPATH=. java -Djava.security.policy="policy.txt" -Djava.rmi.server.codebase="http://mySrcServer/javasrc/dao/bin/ http://mySrcServer/javasrc/rmi/bin/" -Djava.rmi.server.hostname="localhost" com.ugs.xme.rmi.dto.proxy.DTOProxyServer The policy.txt file I'm using looks like: grant { permission java.net.SocketPermission "*", "accept, connect, listen, resolve"; permission java.util.PropertyPermission "*", "read"; permission java.io.FilePermission "<<ALL FILES>>", "read, read, write, delete, execute"; permission java.lang.RuntimePermission "setIO"; }; And I have the following line in my server class: System.setSecurityManager(new java.rmi.RMISecurityManager()); The error that I get when I try to start the service is: Exception in thread "main" java.lang.NoClassDefFoundError: com/ugs/xme/dto/Library at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2365) at java.lang.Class.privateGetPublicMethods(Class.java:2488) at java.lang.Class.getMethods(Class.java:1406) at sun.rmi.server.Util.getRemoteInterfaces(Util.java:221) at sun.rmi.server.Util.getRemoteInterfaces(Util.java:193) at sun.rmi.server.Util.createProxy(Util.java:126) at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:169) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.jav a:293) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.jav a:235) at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:133) at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:119) at com.ugs.xme.rmi.dto.proxy.DTOProxyServerImpl.<init>(DTOProxyServerImpl.j ava:21) at com.ugs.xme.rmi.dto.proxy.DTOProxyServer.<init>(DTOProxyServer.java:17) at com.ugs.xme.rmi.dto.proxy.DTOProxyServer.main(DTOProxyServer.java:52) The Library class it's trying to load is located on the http server (http://mySrcServer/javasrc/dao/bin/). I don't know if my problem is in the security manager setup/permissions or if I'm just not using the codebase property correctly. It looks like the Stub class for my implementation is being loaded from off the http server but the Library class is not. Can someone tell me what I'm doing wrong here, any help would be appreciated. Thanks, David ======================================================================== === To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html