wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes head first rmi error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "head first rmi error" Watch "head first rmi error" New topic
Author

head first rmi error

kieran pattni
Ranch Hand

Joined: Jan 19, 2004
Posts: 47
hi all..copied the head first code examples rmi but get this error ..can anyone help..single on home desktop computer on loop back...


java.net.MalformedURLException: invalid URL String: Remote Hello
at java.rmi.Naming.parseURL(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at MyRemoteImp1.main(MyRemoteImp1.java:44)
Caused by: java.net.URISyntaxException: Illegal character in path at index 6: Remote Hello
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.checkChars(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.rmi.Naming.intParseURL(Unknown Source)
... 3 more

import java.rmi.*;
public interface MyRemote extends Remote
{
public String sayHello() throws RemoteException;
}
import java.rmi.*;
import java.rmi.server.*;

public class MyRemoteImp1 extends UnicastRemoteObject implements MyRemote
{
public String sayHello()
{
return "Server says, 'Hey'";
}
public MyRemoteImp1() throws RemoteException
{

}

public static void main(String[]args)
{
try
{
MyRemote service = new MyRemoteImp1();
Naming.rebind("Remote Hello",service);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
import java.rmi.*;
public class MyRemoteClient
{
public static void main(String[]args)
{
new MyRemoteClient().go();
}
public void go()
{
try
{
MyRemote service = (MyRemote)Naming.lookup("rmi://127.0.0.1/Remote Hello");
String s =service.sayHello();
System.out.println(s);
}
catch(Exception ex){ex.printStackTrace();}


}
}
thank you
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi kieran,

I can't test this at the moment but from the exception you get when trying to run this application I guess the problem is simply the space character between "Remote" and "Hello". I guess you should strip this space out or correctly encode the URL like other URLs (for example HTTP URLs).

I hope this helps...

Marco
kieran pattni
Ranch Hand

Joined: Jan 19, 2004
Posts: 47
thank you...not sure if it is mistake in the book but its working now..thanks
Z Winne
Greenhorn

Joined: Nov 07, 2008
Posts: 5
Ok�, my problem is not the same as the original post but my exercice is. When I run my batch file (%rmic MyRemoteImpl) my command prompt goes haywire, it just keeps giving me the line "--location-->rmic MyRemoteImpl" endlessly. Does anyone have any ideas on what I'm doing wrong?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: head first rmi error