RMI code question.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, April 13, 2002 03:40 PM

Hello, people. I am having problems some with RMI code and I can't figure out what I am doing wrong. I have the following code: sb = new StringBuffer("rmi://localhost/AdmDispositivo"); sb.append(ubicacion); System.out.println("I am asking for the reference to the object factory class"); AdmDispositivoRemoto admDispositivoRemoto = (AdmDispositivoRemoto) Naming.lookup(sb.toString()); Class clase = admDispositivoRemoto.getClass(); /*Here I started to write some debugging code*/ System.out.println(clase); Class[] tiposParametros = {String.class, String.class, String.class, String.class, boolean.class, String.class,}; Method altaDispositivo = clase.getMethod("   More>>

Hello, people. I am having problems some with RMI code and I can't figure out what I am doing wrong.
I have the following code:




			sb = new StringBuffer("rmi://localhost/AdmDispositivo");
			
sb.append(ubicacion);
System.out.println("I am asking for the reference to the object factory class");
AdmDispositivoRemoto admDispositivoRemoto = (AdmDispositivoRemoto) Naming.lookup(sb.toString());
Class clase = admDispositivoRemoto.getClass(); /*Here I started to write some debugging code*/
System.out.println(clase);
Class[] tiposParametros = {String.class, String.class, String.class, String.class, boolean.class, String.class,};
Method altaDispositivo = clase.getMethod("altaDispositivo", tiposParametros);
System.out.println(altaDispositivo);
System.out.println();
Class[] parametros = altaDispositivo.getParameterTypes();
for(int i=0;i
{
System.out.println(parametros[i]);
System.out.println();
}
System.out.println("Got the reference, no I am going to invoke the method");
// admDispositivoRemoto.altaDispositivo(nombre, fabricante, claseFabricante, nombreProtocolo, remoto, ubicacion);
Boolean esRemoto = new Boolean(remoto);
Object[] argumentos = {nombre, fabricante, claseFabricante, nombreProtocolo, esRemoto, ubicacion};
altaDispositivo.invoke(admDispositivoRemoto, argumentos);
System.out.println("I am asking for the remote object reference");
disp = admDispositivoRemoto.referenciaAlDispositivo(nombre);



I changed the admDispositivo.altaDispositivo() for invoke() to see if it could, somehow, solve the problem. Obviously, it didnĀ“t.
The output of this is:



			
I am asking for the reference to the object factory class
class proyectodepurado.rmi.AdmDispositivoRemotoImpl_Stub
public boolean proyectodepurado.rmi.AdmDispositivoRemotoImpl_Stub.altaDispositiv
o(java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean,ja
va.lang.String) throws java.lang.Exception

class java.lang.String

class java.lang.String

class java.lang.String

class java.lang.String

boolean

class java.lang.String

Got the reference, no I am going to invoke the method
java.lang.reflect.InvocationTargetException



When asking for further details I got:
			
java.lang.reflect.InvocationTargetException: java.lang.NoSuchMethodException
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at proyectodepurado.rmi.AdmDispositivoRemotoImpl_Stub.altaDispositivo(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at proyectodepurado.AdmDispositivo.nuevaInstanciaDispositivo(AdmDispositivo.java:108)
at proyectodepurado.AdmDispositivo.actualizarListaDispositivos(AdmDispositivo.java:367)
at proyectodepurado.AdmDispositivo. (AdmDispositivo.java:36)
at proyectodepurado.Aplicacion1.main(Aplicacion1.java:95)



I can't understand why y get the info of my method allright, but I can't invoke it.
All parameters are from the right classes. The reflection code works OK, as I use it in other part of my aplication.
My remote interfaces' code follows:



			
public interface AdmDispositivoRemoto extends java.rmi.Remote
{
public boolean altaDispositivo(String nombre, String fabricante,
String claseFabricante, String nombreProtocolo, boolean remoto, String ubicacion) throws Exception;

public boolean setEnUso(String nombre, boolean libreOUsado) throws java.rmi.RemoteException;

public boolean getEnUso(String nombre) throws java.rmi.RemoteException;

public boolean existeDispositivo(String nombreDispositivo) throws java.rmi.RemoteException;

public String listaDispositivos() throws java.rmi.RemoteException;

public Dispositivo referenciaAlDispositivo(String nombreDispositivo)
throws NoSeEncuentraElDispositivoException, java.rmi.RemoteException;

public boolean bajaDispositivo(String nombreDispositivo)
throws NoSeEncuentraElDispositivoException, NoSeEncuentraElUsuarioException, java.rmi.RemoteException, Exception;

}


I can't figure out what's wrong with this. My AdmDispositivoRemotoImpl is OK, as I had tested it priorly.
Have you got any hints ips, etc.


Thank you very much. Regards,


Juan Pedro    <<Less
About | Sitemap | Contact