Arrêt lors d'un appel RPC
Bonjour tout le monde,
J'utilise le sdk 2.3.0 pour eclipse 3.7.
Je me trouve face à un problème qui m'échappe complétement, lors de l'appel d'une méthode de service, celle-ci ne renvoie rien et stop le traitement en cours. Même en commentant tout le traitement de cette méthode coté serveur et en renvoyant null, cela engendre le même résultat.
Voici le code de la classe faisant l'appel de cette méthode:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
public class Conference extends Composite{
IHMConference parent;
GreetingServiceAsync auth = GWT.create(GreetingService.class);
AsyncCallback<List<User>> callback;
VerticalPanel vp;
List<User> ListUser;
Conference(IHMConference p){
parent = p;
vp = new VerticalPanel();
Label title = new Label("Ma conférence");
title.addStyleName("testLabel");
vp.add(title);
Window.alert(parent.op.getDisplayName());
try{
auth.getConferenceParticipant(parent.op.getDisplayName(),callback);// LA METHODE EN QUESTION !!!!
}catch(Exception e){
e.printStackTrace();
}
callback = new AsyncCallback<List<User>>(){
public void onSuccess(List<User> L){
Window.alert("Requête réussie!");
ListUser = new ArrayList<User>(L);
parcoursListe();
parent.AfficherConference();
}
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
Window.alert(caught.getMessage());
}
};
this.initWidget(vp);
}
private void parcoursListe(){
Label label;
List<User> maList = ListUser;
for (User user : maList) {
label = new Label(user.getLogin()+" "+user.getScriptId().toString());
label.addStyleName("testLabel");
vp.add(label);
}
}
} |
le code de l'interface service coté client:
Code:
1 2 3 4 5 6 7
| @RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
public Boolean registeration(String login, String password, String displayName, String mail, String Ip, String numeroTelephone);
public User authentication(String a, String b) throws UserNotFoundException;
public User change(User b);
public List<User> getConferenceParticipant(String displayName);
} |
le code de l'interface serviceAsync coté client:
Code:
1 2 3 4 5 6
| public interface GreetingServiceAsync {
public void registeration(String login, String password, String displayName, String mail, String Ip, String numeroTelephone, AsyncCallback<Boolean> callback);
public void authentication(String a, String b, AsyncCallback<User> callback);
public void change(User a, AsyncCallback<User> callback);
public void getConferenceParticipant(String displayName, AsyncCallback<List<User>> callback);
} |
Coté server le code de l'implémentation du service:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
/**
* Escape an html string. Escaping data received from the client helps to
* prevent cross-site script vulnerabilities.
*
* @param html the html string to escape
* @return the escaped string
*/
@Override
public User authentication(String a, String b) throws UserNotFoundException {
// TODO Auto-generated method stub
return ServiceFactory.getServiceFactory().getAuthentificationService().authentifier(a, b);
}
@Override
public User change(User b) {
ServiceFactory.getServiceFactory().getAuthentificationService().modifierUser(b);
try {
return ServiceFactory.getServiceFactory().getAuthentificationService().authentifier(b.getLogin(), b.getPassword());
} catch (UserNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
@Override
public Boolean registeration(String login, String password, String displayName, String mail, String Ip, String numeroTelephone) {
// TODO Auto-generated method stub
return ServiceFactory.getServiceFactory().getRegisterationService().register(login,password,displayName,mail,Ip,numeroTelephone);
}
@Override
public List<User> getConferenceParticipant(String displayName) {
return ServiceFactory.getServiceFactory().getConferenceService().getParticipant(displayName);
}
} |
Je ne pense pas nécessaire de vous rajouter le code du serviceFactory ainsi que de l'interface ConferenceService car ils sont simples.
Voici la classe dans laquelle est implémentée la méthode fautive je pense:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| public class MockConferenceService implements ConferenceService {
private static Connection con;
protected PreparedStatement stmt;
List<User> ListUser;
private Map<String, Long> participant = new HashMap<String, Long>();
MockConferenceService(){
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://*******","***","*****");
}
catch(SQLException e){
e.printStackTrace();
}
catch(Exception e){
System.out.println(e);
}
ListUser = new ArrayList<User>();
}
@Override
public List<User> getParticipant(String displayName){
try{
if(con.isClosed()){
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://********","****","*****");
}
}
catch(SQLException e){
e.printStackTrace();
}
catch(Exception e){
System.out.println(e);
}
try {
stmt = con.prepareStatement("Select Confname from Participant where DisplayName=?");
stmt.setString(1, displayName);
ResultSet rs = stmt.executeQuery();
rs.first();
int Confname = rs.getInt("Confname");
stmt = con.prepareStatement("Select * from Participant where Confname=?");
stmt.setInt(1, Confname);
rs = stmt.executeQuery();
while(rs.next()){
this.participant.put(rs.getString("displayName"), rs.getLong("ScriptId"));
}
Set<Map.Entry<String,Long>> set = participant.entrySet();
stmt = con.prepareStatement("Select * from Account where DisplayName=?");
for(Map.Entry<String, Long> itr: set){
stmt.setString(1, itr.getKey());
rs = stmt.executeQuery();
rs.first();
this.ListUser.add(new User(rs.getString("Name"),rs.getString("Password"),rs.getString("Mail"),rs.getString("DisplayName"), itr.getValue()));
}
rs.close();
stmt.close();
con.close();
return ListUser;
}catch (SQLException e) {
e.printStackTrace();
}
return null;
}
} |
Je tiens à vous rappeler que j'ai commenté tout le traitement de la méthode en ne laissant que le return null et que le résultat était le même.
Je vous remercie d'avance pour votre aide.