• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI: remote client without using a web server

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I'm new to RMI and what I want to do should be too difficult.

I'm developing my app on a windows box using NetBeans 6.7
My target client is a pc, my target server is a linux box.

Code compiles.
In testing, if I put the code on the server, it all runs.
(Went through all of the headaches of command line stuff, java.policy and making sure I set it up to use the correct IP Address as hostname.)

But the key is to get this to work in a distributed environment.
So when I test the client code in NetBeans, I can see the registry,
I can see the service, but when I try:


I get the dreaded:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: <My Class here>

message.

On the server, my codebase url is a file:// and not an http://

I don't want to run a web server.

I understand that I can include the server's class files locally and that if they are in my class path. I understand that rmi will check local classpath first and then try to get the file from the remote registry. So to keep it simple, I include the server source code in my client project and build everything. I even edited the ant build.xml to run rmic on my *Impl* classes.

So what am I missing?

To avoid the java.policy issues, I grant permissions toAll. (yes I know its dangerous, but this is still in test and I wanted to remove any issues.)
I tried adding the codebase option on the client side pointing to a jar in c:\tmp as well.

TIA!

-G
javascript:emoticon('');
javascript:emoticon('');
javascript:emoticon('');
 
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't run the http server, then how in the world do you expect the class files to be transmitted to the client? Having a codebase that is a file only works on the local server.

Look up how to start an http server (its all in the doc.) You don't need a web server.
 
Ian Gumby
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, I'm a newbie to rmi and I'm going from what I've read and from the tutorial examples.javascript:emoticon('');

I don't want the remote client to have the class file. I just need the server application to pass the instance and not the class definition. The application is small enough and controlled where the client and the server can actually be in the jar.

From what I could gather from the information online, that if I include the classes in the client jar, which implies that the path should be known, I wouldn't need to get the class from the server.

Essentially the server gets a request, opens a log file, parses the data and sends back a response. Its pretty simple and straight forward.
The catch is that the client is on a remote machine. So all I need is to pass a serialize-able data set. RMI should be able to do this without an http server, right?

I did download the simple http class-server from Sun, but the information on the net imply that I shouldn't need this.

I guess another option would be rmi-iiop. Again I'm going from what I've read.

thanks!
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot pass an instance. An object instance in only valid in a single JVM.

You need to empty your head of all preconceived notions about remote communication and follow the instructions for RMI.
 
Ian Gumby
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Edward Harned wrote:You cannot pass an instance. An object instance in only valid in a single JVM.

You need to empty your head of all preconceived notions about remote communication and follow the instructions for RMI.



Uhm... ok... let me rephrase that.
My impression was that rmi would let me just get the serialized data portion of an object from the remote JVM. That I could have the class files defined locally.
Is this not the case?

But on better news...
javascript:emoticon('');
I did download the simple class files to embed a simple 'Http server'.
The bad news... it only works on files in a given classpath.

So I guess I'll have to work on the getBytes() method to also open files within a jar.

javascript:emoticon('');
(Something I can do in the background, after I finish the client GUI app.)

Thanks for your input.

-G
 
reply
    Bookmark Topic Watch Topic
  • New Topic