Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

How to get RMI to work - stub issues

Thread view: 
Krystian - 23 Nov 2006 13:57 GMT
Hi

I've got a small application written in Java with RMI, but i can't get
it to work.
Here's my directory structure:

D:\Aplikacja\
                -serwer\
                            com.krystian.info.jar
                -klient\
                            test.jar

com.krystian.info.jar is a package with the server, which should send
some system info to the client.
test.jar is a package with client.
Here's what i do:
>start rmiregistry
>java -Djava.rmi.server.codebase=file:\\D:\Aplikacja\serwer\com.krystian.info -Djava.server.policy=java.policy -classpath D:\Aplikacja\serwer\com.krystian.info.jar com.krystian.info.Info info
parameter is the name to bind in the rmiregistry, the server starts
just fine and everything seems to be all right but:
>>java -Djava.security.policy=java.policy test.Test info
parameter is the name to bind in the rmiregistry. Unfortunately when
the client starts i get:
Exception in thread "main" java.rmi.UnmarshalException: error
unmarshalling retu
rn; nested exception is:
       java.lang.ClassNotFoundException: com.krystian.info.Info_Stub
       at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
       at java.rmi.Naming.lookup(Naming.java:84)
       at test.Test.main(Test.java:14)
Caused by: java.lang.ClassNotFoundException:
com.krystian.info.Info_Stub
       at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
       at java.security.AccessController.doPrivileged(Native Method)
.....
but the stub is there!

>jar cvf com.krystian.info.jar com\*
added manifest
adding: com/krystian/(in = 0) (out= 0)(stored 0%)
adding: com/krystian/info/(in = 0) (out= 0)(stored 0%)
adding: com/krystian/info/Info.class(in = 2475) (out= 1298)(deflated
47%)
adding: com/krystian/info/InfoI.class(in = 267) (out= 188)(deflated
29%)
adding: com/krystian/info/Info_Skel.class(in = 1747) (out=
978)(deflated 44%)
adding: com/krystian/info/Info_Stub.class(in = 3370) (out=
1647)(deflated 51%)
adding: com/krystian/info/libuxinfo.sl(in = 20480) (out= 3857)(deflated
81%)
adding: com/krystian/info/Param.class(in = 1286) (out= 735)(deflated
42%)
adding: com/krystian/info/UxInfo.class(in = 2257) (out= 1175)(deflated
47%)
adding: com/krystian/info/WinInfo.class(in = 2279) (out= 1158)(deflated
49%)
adding: com/krystian/info/wininfo.dll(in = 492375) (out=
137023)(deflated 72%)
adding: com/krystian/info/Wyjatek.class(in = 1820) (out= 974)(deflated
46%)

Could somebody explain me what do i do wrong?
I would appreciate it.

Best regards,
Krystian
Nigel Wade - 24 Nov 2006 10:37 GMT
> Hi
>
[quoted text clipped - 14 lines]
>>start rmiregistry
>>java -Djava.rmi.server.codebase=file:\\D:\Aplikacja\serwer\com.krystian.info -Djava.server.policy=java.policy -classpath D
\Aplikacja\serwer\com.krystian.info.jar com.krystian.info.Info info
> parameter is the name to bind in the rmiregistry, the server starts
> just fine and everything seems to be all right but:
[quoted text clipped - 17 lines]
> Could somebody explain me what do i do wrong?
> I would appreciate it.

It's a while since I worked on RMI and rmiregistry, but I think you need to add
the jar to the classpath of rmiregisty if you want rmiregistry to be able to
supply the stubs to the client.

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

EJP - 26 Nov 2006 05:19 GMT
> It's a while since I worked on RMI and rmiregistry, but I think you need to add
> the jar to the classpath of rmiregisty if you want rmiregistry to be able to
> supply the stubs to the client.

No, it's the opposite: if you want the original classpath annotation to
be preserved, the registry must *not* have the classes available on the
classpath.

The OP seems to have left out a .jar on the end of the codebase.
Krystian - 27 Nov 2006 08:32 GMT
> > It's a while since I worked on RMI and rmiregistry, but I think you need to add
> > the jar to the classpath of rmiregisty if you want rmiregistry to be able to
[quoted text clipped - 5 lines]
>
> The OP seems to have left out a .jar on the end of the codebase.

hmm...
how to do it?
How to add or remove a classpath from rmregistry?
I don't know how to do it with rmiregistry, i only know how to do it
with a java app.
I add the jar there, because the whole app is in jar and i start it
from there.

Best regards,
Krystian
EJP - 28 Nov 2006 01:56 GMT
> How to add or remove a classpath from rmregistry?

Don't.

> I add the jar there, because the whole app is in jar and i start it
> from there.

I agree but you have
-Djava.rmi.server.codebase=file:\\D:\Aplikacja\serwer\com.krystian.info

Surely this should be

-Djava.rmi.server.codebase=file:\\D:\Aplikacja\serwer\com.krystian.info.jar

???
Krystian - 28 Nov 2006 08:06 GMT
> > How to add or remove a classpath from rmregistry?
>
[quoted text clipped - 11 lines]
>
> ???

I've tried, nothing has changed :/
Server starts normally, client doesn't:

>java -Djava.security.policy=java.policy test.Test info
Exception in thread "main" java.rmi.UnmarshalException: error
unmarshalling retu
rn; nested exception is:
       java.lang.ClassNotFoundException: com.krystian.info.Info_Stub
       at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
       at java.rmi.Naming.lookup(Naming.java:84)
       at test.Test.main(Test.java:13)
Caused by: java.lang.ClassNotFoundException:
com.krystian.info.Info_Stub
       at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
EJP - 28 Nov 2006 09:23 GMT
This means that the registry had the classes on its classpath. Start it
from somewhere else other than the root directory of your package/class
hierarchy, i.e. somewhere where a classpath of '.' won't find your
.class files.
Nigel Wade - 28 Nov 2006 11:56 GMT
>> It's a while since I worked on RMI and rmiregistry, but I think you need to add
>> the jar to the classpath of rmiregisty if you want rmiregistry to be able to
[quoted text clipped - 3 lines]
> be preserved, the registry must *not* have the classes available on the
> classpath.

It is a while since I used RMI... and memory fades.

I had a recollection that at one point I'd had a similar problem, and I thought
it was due to the rmiregisty not having access to the classes.

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Krystian - 29 Nov 2006 08:47 GMT
> >> It's a while since I worked on RMI and rmiregistry, but I think you need to
> add
[quoted text clipped - 15 lines]
> E-mail :    nmw@ion.le.ac.uk
> Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Thank You guys for reply,

I have started rmiregistry from a different location and now... server
won't start:

>java -Djava.rmi.server.codebase=file:\\D:\Aplikacja\serwer\com.krystian.info.jar -Djava.server.policy=java.policy -classpath D:\Aplikacja\serwer\com.krystian.info.jar com.krystian.info.Info info info
Exception in thread "main" java.rmi.ServerException: RemoteException
occurred in
server thread; nested exception is:
       java.rmi.UnmarshalException: error unmarshalling arguments;
nested excep
tion is:
       java.lang.ClassNotFoundException: com.krystian.info.Info_Stub
       at
sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:352
)
       at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
       at sun.rmi.transport.Transport$1.run(Transport.java:148)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
       at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
       at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
       at java.lang.Thread.run(Thread.java:534)
       at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)

Now i really have no idea what's going on :/
Damn... this should be so easy... :/
Krystian - 29 Nov 2006 09:31 GMT
> > >> It's a while since I worked on RMI and rmiregistry, but I think you need to
> > add
[quoted text clipped - 50 lines]
> Now i really have no idea what's going on :/
> Damn... this should be so easy... :/

LOL.

i think i  solved it...
the problem was with file:// instead of file:/// ;>

Now i've got  a new issue with client:

java.lang.ClassCastException
    at test.Test.main(Test.java:13)
Exception in thread "main"

The line is:
 InfoI t = (InfoI)Naming.lookup(arg[0]);

where InfoI is the name of the interface i send trough RMI.
Have You got any idea what's causing it?

I've tried to change arg[0] to "info" but it doesn't change anything :/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.