IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GWT et Vaadin Java Discussion :

Erreurs au niveau de GWT (GWT + Hibernate + Spring)


Sujet :

GWT et Vaadin Java

  1. #1
    Membre du Club
    Inscrit en
    Mars 2012
    Messages
    165
    Détails du profil
    Informations forums :
    Inscription : Mars 2012
    Messages : 165
    Points : 59
    Points
    59
    Par défaut Erreurs au niveau de GWT (GWT + Hibernate + Spring)
    Bonjour,

    Je suis débutant en GWT. Je commence à faire une application GWT dont j'utilise aussi Hibernate et Spring.

    Je rencontre des erreurs lors de l'exécution au niveau de GWT.

    Voilà la structure de mon application :



    Voilà ma classe GWT_Test1.java :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    package com.afkir.client;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import org.springframework.context.support.ClassPathXmlApplicationContext;
     
    import com.afkir.model.User;
    import com.afkir.shared.FieldVerifier;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.event.dom.client.ClickEvent;
    import com.google.gwt.event.dom.client.ClickHandler;
    import com.google.gwt.event.dom.client.KeyCodes;
    import com.google.gwt.event.dom.client.KeyUpEvent;
    import com.google.gwt.event.dom.client.KeyUpHandler;
    import com.google.gwt.event.logical.shared.SelectionEvent;
    import com.google.gwt.event.logical.shared.SelectionHandler;
    import com.google.gwt.user.client.Window;
    import com.google.gwt.user.client.WindowResizeListener;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.google.gwt.user.client.ui.Button;
    import com.google.gwt.user.client.ui.DialogBox;
    import com.google.gwt.user.client.ui.DockPanel;
    import com.google.gwt.user.client.ui.FlexTable;
    import com.google.gwt.user.client.ui.Grid;
    import com.google.gwt.user.client.ui.HTML;
    import com.google.gwt.user.client.ui.HorizontalPanel;
    import com.google.gwt.user.client.ui.Label;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.TabPanel;
    import com.google.gwt.user.client.ui.TextBox;
    import com.google.gwt.user.client.ui.VerticalPanel;
     
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class GWT_Test1 implements EntryPoint {
     
    private static final int LIST_TAB_INDEX = 2; 
     
    	//ui
    	private final TabPanel tabPanel = new TabPanel();
    	private Grid createContent;
    	private FlexTable listContent = new FlexTable();
     
    	private final TextBox txtNewProductId = new TextBox();
    	private final TextBox txtNewProductName = new TextBox();
    	private final TextBox txtNewProductVendorName = new TextBox();
    	private final Button btnSaveNewProduct = new Button("Save");
     
     
    	//service
    	private UserServiceAsync userService = GWT.create(UserService.class);
     
    	public void onModuleLoad() {
     
    		createContent = createCreateContent();
     
    		tabPanel.setStyleName("tabPanel");
     
    		tabPanel.add(createContent, "Create Product");
    		tabPanel.add(listContent, "List Products");
    		tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
     
    			@Override
    			public void onSelection(SelectionEvent<Integer> event) {
    				if (event.getSelectedItem() == LIST_TAB_INDEX) {
    					//we're in list-products
     
    					//clear list
    					listContent.removeAllRows();
     
    					listContent.setText(0, 0, "Id");
    					listContent.setText(0, 1, "Name");
    					listContent.setText(0, 2, "Surname");
     
    					userService.list(new AsyncCallback<List<User>>() {
     
    						@Override
    						public void onFailure(Throwable caught) {
    							Window.alert(caught.getMessage());
    						}
     
    						@Override
    						public void onSuccess(List<User> result) {
    							for(User user : result) {
     
    								int row = listContent.getRowCount();
    								listContent.setText(row, 0, user.getId() + "");
    								listContent.setText(row, 1, user.getName());
    								listContent.setText(row, 2, user.getSurname());
    							}
    						}
     
    					});
    				}
    			}
    		});
     
    		RootPanel.get("root").add(tabPanel);
     
    		tabPanel.selectTab(0);
    	}
     
    	private Grid createCreateContent() {
    		Grid grid = new Grid(6, 2);
     
    		grid.setText(0, 0, "Product Id:");
    		grid.setWidget(0, 1, txtNewProductId);
     
    		grid.setText(0, 0, "Product Name:");
    		grid.setWidget(0, 1, txtNewProductName);
     
    		grid.setText(1, 0, "Vendor Name:");
    		grid.setWidget(1, 1, txtNewProductVendorName);
     
    		grid.setText(4, 0, "");
    		grid.setText(4, 1, "");
     
    		grid.setText(5, 0, "");			
    		grid.setWidget(5, 1, btnSaveNewProduct);
     
    		btnSaveNewProduct.addClickHandler(new ClickHandler() {
     
    			@Override
    			public void onClick(ClickEvent event) {
    				User user = new User();
    				user.setId(Integer.parseInt(txtNewProductName.getText()));
    				user.setName(txtNewProductName.getText());
    				user.setSurname(txtNewProductVendorName.getText());
    				List<String> users = new ArrayList<String>();
     
    				userService.save(user, new AsyncCallback<Void>() {
     
    					@Override
    					public void onSuccess(Void result) {
    						Window.alert("Product successfully saved!");
    						clearNewForm();
    					}
     
    					@Override
    					public void onFailure(Throwable caught) {
    						Window.alert(caught.getMessage());
    					}
    				});
    			}
    		});
     
    		return grid;
    	}
     
    	private void clearNewForm() {
    		txtNewProductId.setText("");
    		txtNewProductName.setText("");
    		txtNewProductVendorName.setText("");
    	}
     
    }
    Voilà mon interface UserService :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    package com.afkir.client;
     
    import java.util.List;
     
    import com.afkir.model.User;
    import com.google.gwt.user.client.rpc.RemoteService;
    import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
     
    @RemoteServiceRelativePath("userServices/userService")
    public interface UserService extends RemoteService {
     
    	public List<User> list();
    	public void save(User user);
     
    }
    Voilà mon interface UserServiceAsync :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    package com.afkir.client;
     
    import java.util.List;
     
    import com.afkir.model.User;
    import com.google.gwt.user.client.rpc.AsyncCallback;
     
    public interface UserServiceAsync {
     
    	void list(AsyncCallback<List<User>> callback);
    	void save(User user, AsyncCallback<Void> callback);
     
    }
    Voilà ma classe UserServiceImpl :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    package com.afkir.server;
     
    import java.util.List;
     
    import org.hibernate.SessionFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
     
    import com.afkir.client.UserService;
    import com.afkir.model.User;
     
    @Service("userService")
    @Transactional
    public class UserServiceImpl implements UserService {
     
    	@Autowired
    	private SessionFactory sessionFactory;
     
    	@Override
    	public List<User> list() {
    		return sessionFactory.getCurrentSession().createQuery("from User").list();
    	}
     
    	@Override
    	public void save(User user) {
    		sessionFactory.getCurrentSession().save(user);
    	}
     
    }
    Voilà mon fichier web.xml :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <?xml version="1.0" encoding="UTF-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     
        <listener>		
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	<listener>
           <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
      	</listener>
     
    	<context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </context-param>
     
    	<servlet>
     		<servlet-name>spring4gwt</servlet-name>
     		<servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet</servlet-class>
      	</servlet>
      	<servlet-mapping>
     		<servlet-name>spring4gwt</servlet-name>
     		<url-pattern>/GWT_Test1/userServices/*</url-pattern>
      	</servlet-mapping>
      	
      <!-- Servlets -->
      <servlet>
        <servlet-name>greetServlet</servlet-name>
        <servlet-class>com.afkir.server.GreetingServiceImpl</servlet-class>
      </servlet>
      
      <servlet-mapping>
        <servlet-name>greetServlet</servlet-name>
        <url-pattern>/gwt_test1/greet</url-pattern>
      </servlet-mapping>
      
      <!-- Default page to serve -->
      <welcome-file-list>
        <welcome-file>GWT_Test1.html</welcome-file>
      </welcome-file-list>
     
      <servlet>
        <servlet-name>SystemServiceServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
        <init-param>
          <param-name>services</param-name>
          <param-value/>
        </init-param>
      </servlet>
     
      <servlet-mapping>
        <servlet-name>SystemServiceServlet</servlet-name>
        <url-pattern>/_ah/spi/*</url-pattern>
      </servlet-mapping>
     
    </web-app>
    Voilà les erreurs que je rencontre :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    [TRACE] [gwt_test1] - Finding entry point classes
    	[ERROR] [gwt_test1] - Errors in 'file:/Q:/Apache%20Software%20Foundation/Tomcat%206.0/webapps/GWT_Test1/src/com/afkir/client/GWT_Test1.java'
    		[ERROR] [gwt_test1] - Line 78: No source code is available for type com.afkir.model.User; did you forget to inherit a required module?
    	[ERROR] [gwt_test1] - Errors in 'file:/Q:/Apache%20Software%20Foundation/Tomcat%206.0/webapps/GWT_Test1/src/com/afkir/client/UserServiceAsync.java'
    		[ERROR] [gwt_test1] - Line 10: No source code is available for type com.afkir.model.User; did you forget to inherit a required module?
    	[ERROR] [gwt_test1] - Unable to find type 'com.afkir.client.GWT_Test1'
    		[ERROR] [gwt_test1] - Hint: Previous compiler errors may have made this type unavailable
    		[ERROR] [gwt_test1] - Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
    [ERROR] [gwt_test1] - Failed to load module 'gwt_test1' from user agent 'Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0' at localhost127.0.0.1:6122
    J'ai besoin de vos renseignements,

    Merci bien d'avance.
    Images attachées Images attachées  

Discussions similaires

  1. Réponses: 40
    Dernier message: 04/05/2011, 00h12
  2. GWT 2.0 + Spring + Hibernate -> Intégrer Gilead
    Par valery.stroeder dans le forum GWT et Vaadin
    Réponses: 0
    Dernier message: 21/01/2010, 16h29
  3. Réponses: 0
    Dernier message: 01/12/2009, 11h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo