Problème " Method not supported by remote object" methode d'une interface cliente
Bonjour à tous .
j'aimerai résoudre un probléme de cast sur une classe. Je travaille sur un projet RMI.
partie Serveur :
( interface ) Connection.java
Code:
1 2 3 4 5 6 7 8 9
|
public interface ConnectionFactory extends Remote{
public Connection getConnection() throws SQLException, RemoteException ;
public ConnectionFactoryImpl getInstance() throws RemoteException;
} |
Ma fonction getInstance retourne un objet ConnectionFactoryImpl
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public ConnectionFactoryImpl getInstance() throws RemoteException {
ConnectionFactoryImpl connectionFactory = null;
try {
// GetInstanceV me permet de pouvoir me connecter à une base de donnée ( methode static )
connectionFactory = getInstanceV();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("getInstance");
return connectionFactory;
} |
j'ai créer cette méthode car je ne pouvais pas faire autrement.
Partie client :
INterface
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
package service;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.SQLException;
public interface ConnectionFactory extends Remote{
public Connection getConnection() throws SQLException, RemoteException ;
public Object getInstance() throws RemoteException;
} |
Mon Main Client.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
public class Client {
...
public Client(){
try {
ConnectionFactory stub = (ConnectionFactory) Naming.lookup("rmi://localhost:10999/BDD");
stub.getInstance();
entier = fichierMathML_DAO.add(objetEntrer);
fichierMathML_DAO = stub.getFichierDAO();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
Mon erreur concerne donc un problème de cast sur ma methode Interface Client :
public Object getInstance() throws RemoteException;
Je ne peux pas faire public ConnectionFactoryImpl getInstance() throws RemoteException; dans ma partie client.
Est ce qu'il y aurai un autre moyen pour obtenir un objet de ma classe implémenté qui support RemoteObjet parce que je bute depuis un moment dessus et je bloque.
merci d'avance.