Ian Gumby

Greenhorn
+ Follow
since Sep 11, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ian Gumby

I finally got my rmi based client/server app working.

But I had hit a bit of a wall and today I created a solution.. javascript:emoticon('');

Since I didn't want to create a complete web service, I chose to use the sample class-server.zip from Sun.

It works ok if you are going to put your class files in a directory and you just point to the directory.
It fails miserably when you keep your files in a jar file and just point your codebase to your jar file.
(The simple class doesn't know how to handle jars.)

So I ran in to a little roadblock that didn't make sense....javascript:emoticon(''); .
When I started the server, I could see the registry, but when I was rebinding my instance, it blew up.
javascript:emoticon('');

It turns out that when I did the binding/rebinding of my implementation class, under the covers, the registry is trying to get a copy of the entire jar file.
This was unexpected. Well I fixed the code to handle a jar file request, and it works, but I'm still confused.

I had thought that the registry would have gone to the jar file and requested the single class file. (I had already written the code to handle those cases using a JarFile object....

So my question is why did the registry wan't the entire jar file when I called registry.rebind("Service",obj) ?

Still learning ... javascript:emoticon('');

Thanks
14 years ago

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
14 years ago
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!
14 years ago
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('');
14 years ago