Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: rmi problems

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rmi problems

    i'm trying to create a basic hello world for rmi .

    server code:


    import java.net.InetAddress;
    import java.net.MalformedURLException;
    import java.net.UnknownHostException;
    import java.rmi.AlreadyBoundException;
    import java.rmi.Naming;
    import java.rmi.RMISecurityManager;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
     
     
    public class server extends UnicastRemoteObject implements dostuff{
     
    	protected server() throws RemoteException {
     
     
    	}
     
     
     
    	public static void main(String args[])
    	{
    		System.setSecurityManager(new RMISecurityManager());
     
    		try {
    			String computername=InetAddress.getLocalHost().getHostName();
    			server s = new server();
    			try {
    				Naming.bind("//"+computername+"/server", s);
    				System.out.println("server started");
    			} catch (MalformedURLException e) {
     
    				e.printStackTrace();
    			} catch (AlreadyBoundException e) {
     
    				e.printStackTrace();
    			}
    		} catch (RemoteException e) {
     
    			e.printStackTrace();
    		} catch (UnknownHostException e) {
     
    			e.printStackTrace();
    		}
    	}
     
     
     
    	@Override
    	public String doesitwork() {
     
    		return "yes";
    	}
     
    }

    interface:


    i
    mport java.rmi.*;
     
     
     interface dostuff extends Remote{
     
    	public String doesitwork() throws RemoteException;
     
    }


    i run the server in eclipse with VM arguments -Djava.rmi.server.codebase=${container_loc} -Djava.security.policy policy.txt. the policy just gives all permissions.

    i get the exception

    Java.rmi.unmarshalException Error unmarshalling return; nested exception is:
    java.net.malformedURLException: unknown protocol g
    etc.

    the external hard drive my java projects is on shows up as G:.

    what's the problem here?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: rmi problems

    Looks like some code is eating a full path as a URL: G:\folder\subfolder\...
    URLs start with a protocol followed by a :
    so G:\ would look like protocol G

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: rmi problems

    thought so. how can i fix this?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: rmi problems

    Where is it getting the G: from?

    Does the error message have a source code line number in it? the 'etc.' in your post probably showed it.

  5. #5
    Junior Member
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: rmi problems

    it's coming form the Naming.Bind() call, i think.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: rmi problems

    Why do you think that?
    Can you post ALL of the error message?

  7. #7
    Junior Member
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: rmi problems

    java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
    java.net.MalformedURLException: unknown protocol: g
    at sun.rmi.transport.StreamRemoteCall.executeCall(Unk nown 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 server.main(server.java:29)
    Caused by: java.net.MalformedURLException: unknown protocol: g
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at sun.rmi.server.LoaderHandler.pathToURLs(Unknown Source)
    at sun.rmi.server.LoaderHandler.getDefaultCodebaseURL s(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(Unk nown Source)
    at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unkno wn Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    ... 5 more


    this is what showed up in the eclipse console

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: rmi problems

    java.net.MalformedURLException: unknown protocol: g
    Did you ever resolve where the "g" was coming from?
    Are you using a disk (g:/)address instead of an http:// address?

Similar Threads

  1. [SOLVED] ProgramMenuBar problems
    By javapenguin in forum What's Wrong With My Code?
    Replies: 10
    Last Post: August 9th, 2010, 04:34 AM
  2. Image problems
    By Bekuraryou1228 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 19th, 2010, 05:53 PM
  3. Problems with If validation
    By websey in forum Loops & Control Statements
    Replies: 1
    Last Post: November 18th, 2009, 09:43 AM
  4. How to compile and run java program?
    By ebalari56 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 27th, 2009, 09:33 PM
  5. If you have any .NET problems
    By antony_t in forum The Cafe
    Replies: 1
    Last Post: August 26th, 2009, 10:49 AM