Re: Please Help Me

Gregg Wonderly <[email protected]> Wed, 27 Sep 2006 15:43:07 -0500
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Tatiana Pereira Filgueiras wrote:
> I'm trying to make a calculator server using javaspaces for a month but I
> can't do it ... anybody here have a calculator server with remote client
> source code? What I do with this code below???
>
> see my problems
>
> C:\Documents and Settings\Tati\Desktop\Pesquisas\pratica\Tentativa2>java -classp
> ath .\;"C:\Arquivos de programas\jini2_1\lib\jini-ext.jar";"C:\Documents and Set
> tings\Tati\Desktop\Pesquisas\pratica\pac.jar";"C:\Arquivos de programas\jini2_1\
> lib\reggie.jar";"C:\Arquivos de programas\jini2_1\lib\outrigger.jar";"C:\Arquivo
> s de programas\jini2_1\lib\jini-core.jar" Cliente
> Localizando JavaSpace...
>
> JavaSpace localizado.
>
> java.rmi.ServerException: RemoteException in server thread; nested exception is:
>
>         java.rmi.UnmarshalException: unmarshalling method/arguments; nested exce
> ption is:
>         java.lang.ClassNotFoundException: Calculadora2App.Resultado

> My codes:
>
> Cliente.java

Tatiana, this is not a code problem.  This is a configuration problem.  It
appears you are sending code between machines, and not providing a way for the
receiving machine to get the definition of the classes it is receiving.  You
need to setup your codebase correctly by putting all of the classes which are
being sent between machines, into a jar file.  Then, you need to set the system
property, java.rmi.server.codebase to a URL which will allow this jar file to be
found and loaded.

So, for example, add

        -Djava.rmi.server.codebase=http://somehost/jars/resultado.jar

to your java command line on all java applications which are using these
classes.  Next, configure a web server to work as required by the URL you supply
for the above property.

There is more information on this aspect of Java mobile code visible in many
places on the web and in the Jini documentation.  If you search for
java.rmi.server.codebase, you should be able to find more descriptions of what
is needed to help you get things configured correctly.

There is no magic here.  There is not an automatic code wrapping and transport
mechanism.  When you send Java objects across the network, the class files have
to be available on the receiving machine.  The codebase mechanism is the most
flexible mechanism because it allows the server to be in charge of what version
of which classes everyone sees.  If you put the classes into the classpath of
every user of the classes, it would work that way too, but when you update the
classes, you have to send them to, or install them on all users machines.

Gregg Wonderly

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html