Re: Please Help Me

Shay Hassidim <[email protected]> Wed, 27 Sep 2006 22:58:12 +0200
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Tatiana,

 

You may download GigaSpaces Community Edition (it is free) from
http://gigaspaces.com/os_downloads.html  and extract the zip.

 

For notify example see:

:\GigaSpacesEE5.1\examples\Basic\helloSpace\src\com\j_spaces\examples\hellos
pace\HelloWorldNotify.java

To run it cd to:

:\GigaSpacesEE5.1\examples\Basic\helloSpace\bin\ 

startAll.bat – To star the space

run_HelloWorldNotify.bat – to run the application

 

For Master/Worker - calculator server see:

:\GigaSpacesEE5.1\examples\Advanced\Compute_Grid\masterworker-simple

 

See more here:

http://gigaspaces.com/wiki/display/GS/JavaSpaces

http://www.gigaspaces.com/docs/examples/Basic/helloSpace/index.htm

 

Shay

 

 

-----Original Message-----
From: Tatiana Pereira Filgueiras [mailto:[email protected]] 
Sent: Wednesday, September 27, 2006 9:31 PM
To: [email protected]
Subject: Please Help Me

 

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

        at
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvocationDispa

tcher.java:644)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$6.run(ObjectTable.java

:597)

        at
net.jini.export.ServerContext.doWithServerContext(ServerContext.java:

103)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch0(Objec

tTable.java:595)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.access$700(Obje

ctTable.java:212)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$5.run(ObjectTable.java

:568)

        at
com.sun.jini.start.AggregatePolicyProvider$6.run(AggregatePolicyProvi

der.java:527)

        at java.security.AccessController.doPrivileged(Native Method)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(Object

Table.java:565)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(Object

Table.java:540)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(ObjectTabl

e.java:778)

        at
net.jini.jeri.connection.ServerConnectionManager$Dispatcher.dispatch(

ServerConnectionManager.java:148)

        at
com.sun.jini.jeri.internal.mux.MuxServer$2.run(MuxServer.java:244)

        at
com.sun.jini.start.AggregatePolicyProvider$5.run(AggregatePolicyProvi

der.java:513)

        at java.security.AccessController.doPrivileged(Native Method)

        at
com.sun.jini.jeri.internal.mux.MuxServer$1.run(MuxServer.java:241)

        at com.sun.jini.thread.ThreadPool$Worker.run(ThreadPool.java:136)

        at java.lang.Thread.run(Thread.java:595)

        at
com.sun.jini.jeri.internal.runtime.Util.__________EXCEPTION_RECEIVED_

FROM_SERVER__________(Util.java:108)

        at
com.sun.jini.jeri.internal.runtime.Util.exceptionReceivedFromServer(U

til.java:101)

        at
net.jini.jeri.BasicInvocationHandler.unmarshalThrow(BasicInvocationHa

ndler.java:1303)

        at
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce(BasicInvo

cationHandler.java:832)

        at
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(BasicInvocati

onHandler.java:659)

        at
net.jini.jeri.BasicInvocationHandler.invoke(BasicInvocationHandler.ja

va:528)

        at com.sun.jini.outrigger.$Proxy1.notify(Unknown Source)

        at com.sun.jini.outrigger.SpaceProxy2.notify(SpaceProxy2.java:507)

        at Cliente.main(Cliente.java:33)

Caused by: java.rmi.UnmarshalException: unmarshalling method/arguments;
nested e

xception is:

        java.lang.ClassNotFoundException: Calculadora2App.Resultado

        at
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvocationDispa

tcher.java:619)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$6.run(ObjectTable.java

:597)

        at
net.jini.export.ServerContext.doWithServerContext(ServerContext.java:

103)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch0(Objec

tTable.java:595)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.access$700(Obje

ctTable.java:212)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$5.run(ObjectTable.java

:568)

        at
com.sun.jini.start.AggregatePolicyProvider$6.run(AggregatePolicyProvi

der.java:527)

        at java.security.AccessController.doPrivileged(Native Method)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(Object

Table.java:565)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(Object

Table.java:540)

        at
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(ObjectTabl

e.java:778)

        at
net.jini.jeri.connection.ServerConnectionManager$Dispatcher.dispatch(

ServerConnectionManager.java:148)

        at
com.sun.jini.jeri.internal.mux.MuxServer$2.run(MuxServer.java:244)

        at
com.sun.jini.start.AggregatePolicyProvider$5.run(AggregatePolicyProvi

der.java:513)

        at java.security.AccessController.doPrivileged(Native Method)

        at
com.sun.jini.jeri.internal.mux.MuxServer$1.run(MuxServer.java:241)

        at com.sun.jini.thread.ThreadPool$Worker.run(ThreadPool.java:136)

        at java.lang.Thread.run(Thread.java:595)

Caused by: java.lang.ClassNotFoundException: Calculadora2App.Resultado

        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

        at
net.jini.loader.pref.PreferredClassLoader.loadClass(PreferredClassLoa

der.java:922)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:242)

        at
net.jini.loader.pref.PreferredClassProvider.loadClass(PreferredClassP

rovider.java:613)

        at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)

        at net.jini.loader.ClassLoading.loadClass(ClassLoading.java:138)

        at
net.jini.io.MarshalInputStream.resolveClass(MarshalInputStream.java:2

96)

        at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:154

4)

        at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)

        at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

699)

        at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)

        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)

        at
com.sun.jini.jeri.internal.runtime.Util.unmarshalValue(Util.java:221)

 

        at
net.jini.jeri.BasicInvocationDispatcher.unmarshalArguments(BasicInvoc

ationDispatcher.java:1049)

        at
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvocationDispa

tcher.java:599)

        ... 17 more

Pressione qualquer tecla para continuar. . .

 

My codes:

 

Cliente.java

 

import Calculadora2App.*;

 

import java.io.Serializable;

import java.util.Scanner;

import net.jini.space.JavaSpace;

import net.jini.core.lease.Lease;

import net.jini.core.event.RemoteEvent;

import net.jini.core.event.RemoteEventListener;

import java.lang.*;

 

public class Cliente{ //implements RemoteEventListener,Serializable{

 

 private JavaSpace space;

 

 public Cliente(){}

 

 public Cliente(JavaSpace space){

  this.space = space;

  }

 

 public static void main(String[] args){

 

 try {

  // ************* Fazendo Lookup para achar o espaço
***********************

 

  Utilidades conexao = new Utilidades();

  JavaSpace space = conexao.conecta();

  Cliente setar = new Cliente(space);

 

  // ************** Registrando cliente para receber notificação de

resultado **************

 

  Resultado usuario = new Resultado(space);

  Resultado template = new Resultado();

  space.notify(template, null,usuario, Lease.FOREVER, null);

   //

****************************************************************************
***********

 

  Scanner sc = new Scanner(System.in);

        CalcEntry msg = new CalcEntry(); // Entry de requisição de calculos

 

 

   System.out.println("************************************************\n");

   System.out.println("Digite o numero da operacao desejada:\n");

   System.out.println("1. Adicao\n");

   System.out.println("2. Subtracao:\n");

   System.out.println("3. Multiplicacao\n");

   System.out.println("4. Divisao\n");

   System.out.println("************************************************\n");

 

 

//**************************************************************************
**************

 

 

  msg.operacao = new Integer(sc.nextInt());

  System.out.println("Digite o primeiro numero: ");

  msg.op1 = new Integer(sc.nextInt());

  System.out.println("\nDigite o segundo numero:");

  msg.op2 = new Integer(sc.nextInt());

 

  //****************************** Usando write para escrever no espaço

*********************

  conexao.escreve(msg,space);

 

    }

    catch (Exception e){

         e.printStackTrace();

         }

 }

 

Resultado.java

 

import net.jini.core.lease.Lease;

import net.jini.core.event.RemoteEvent;

import net.jini.core.event.RemoteEventListener;

 

public class Resultado implements Entry,RemoteEventListener,Serializable {

 public Integer resultado;

 private JavaSpace space;

 

 public Resultado(){}

 public Resultado(JavaSpace space){

  this.space = space;

 }

 

 public void notify(RemoteEvent evento){

 

  System.out.println("Evento recebido. Tentando retirar do
espaco........\n");

 

  Resultado resulEntry = new Resultado();

 

  //loop para tirar todas as entrys do espaço

  while(resulEntry == null){

   try{

   resulEntry = (Resultado)space.take(resulEntry,null,Long.MAX_VALUE);

   System.out.println("\nResultado da operacao:

"+resulEntry.resultado.intValue());

   }

  catch(Exception e){

   System.err.println("Erro ao retirar do espaço\n");

   e.printStackTrace();

  }

 }

  }

 }

 

===========================================================================

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


===========================================================================
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