Wednesday, September 28, 2011

Request for help with Request Factory and Spring MVC integration


Can anyone please help me out on the below? I am new to GWT and I have been trying a lot to get a starter app running using GWT, Spring and hibernate.

I was able to set up basic app but now I want to use RequestFactory with Spring MVC. After searching a lot I came across few links to get started but I am not able to completely figure out how to get the configuration right, and my app is not working :( . 

Can anyone please suggest me where I can get a sample app with RequestFactory and SpringMVC configured so that I can get the settings right. Or help me to get my app running. 

I am using GWT 2.4 and spring 3.

My web.xml is : 


<!-- Default page to serve -->



<!-- Spring context -->

<!-- SpringGwt remote service servlet -->




<?xml version="1.0" encoding="UTF-8"?>
<bean id="urlMapping"
<property name="mappings">
<bean id="gwtSpringServiceLayerDecorator"
class="org.spring4gwt.examples.simplerpc.server.servlet.GWTSpringServiceLayerDecorator" />
<bean id="defaultExceptionHandler"
class="" />
<!-- RequestFactoryServlet bean is scoped as singleton. Injecting custom 
SpringServiceLayerDecorator. -->
<bean id="requestFactoryServlet"
<constructor-arg ref="defaultExceptionHandler" />
<constructor-arg ref="gwtSpringServiceLayerDecorator" />
<bean id="gwtSpringEntityLocator"
class="org.spring4gwt.examples.simplerpc.server.servlet.GWTSpringEntityLocator" />
<bean id="gwtSpringServiceLocator"
class="org.spring4gwt.examples.simplerpc.server.servlet.GWTSpringServiceLocator" />
<!-- IMPORTANT NOTE: CustomServletWrappingController is a hacked version 
of ServletWrappingController. The servlet class defined here will not be 
used. Please see CustomServletWrappingController for more information. -->
<bean id="gwtRequestFactoryController"
<property name="servletClass">
<property name="servletName">

@Service(locator = GWTSpringServiceLocator.class, value = EmployeeRequest.class)
public interface EmployeeRequest extends RequestContext {

Request<EmployeeProxy> findEmployee(Long id);

InstanceRequest<EmployeeProxy, Void> persist();

EmployeeProxy .java

@ProxyFor(value = EmployeeDTO.class, locator = GWTSpringEntityLocator.class)
public interface EmployeeProxy extends EntityProxy {

String getEmployeeName();

String getEmployeeSurname();

Long getEmployeeId();

String getJob();

void setEmployeeName(String employeeName);

void setEmployeeSurname(String employeeSurname);

void setJob(String job);

void setEmployeeId(long employeeId);

@Table(name = "EMPLOYEE")
public class EmployeeDTO implements {
    private static final long serialVersionUID = 7440297955003302414L;

    private long employeeId;
    @Column(name="employee_name", nullable = false, length=30)
    private String employeeName;
    @Column(name="employee_surname", nullable = false, length=30)
    private String employeeSurname;
    @Column(name="job", length=50)
    private String job;
    public EmployeeDTO() {

    public EmployeeDTO(int employeeId) {
        this.employeeId = employeeId;        

    public EmployeeDTO(long employeeId, String employeeName, String employeeSurname,
            String job) {
        this.employeeId = employeeId;
        this.employeeName = employeeName;
        this.employeeSurname = employeeSurname;
        this.job = job;

    public long getEmployeeId() {
        return employeeId;

    public void setEmployeeId(long employeeId) {
        this.employeeId = employeeId;

    public String getEmployeeName() {
        return employeeName;

    public void setEmployeeName(String employeeName) {
        this.employeeName = employeeName;

    public String getEmployeeSurname() {
        return employeeSurname;

    public void setEmployeeSurname(String employeeSurname) {
        this.employeeSurname = employeeSurname;

    public String getJob() {
        return job;

    public void setJob(String job) {
        this.job = job;


public interface EmployeeService {
    public EmployeeDTO findEmployee(long employeeId);
    public void persist(EmployeeDTO employeeDTO);

public class EmployeeServiceImpl implements EmployeeService{ 
    private EmployeeDAO employeeDAO; 

    public void init() throws Exception { 
    public void destroy() { 

    public EmployeeDTO findEmployee(long employeeId) { 
        return employeeDAO.findById(employeeId); 
    @Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
    public void persist(EmployeeDTO employeeDTO) {
    if(employeeDTO == null) { 

In my onModuleLoad method where I have the event for a button click on the page I am doing this

 EmployeeRequest request = requestFactory.employeeRequest();
 EmployeeProxy newEmployee = request.create(EmployeeProxy.class);

 Request<Void> createReq = request.persist().using(newEmployee);

           new Receiver<EmployeeProxy>() {
             public void onSuccess(EmployeeProxy employee) {
             dialogBox.setText("Remote Procedure Call");

The call for persist using request does not do anything. And the call to findEmployee throws a null pointer exception.

The locators I am using are attached in the mail. 

Please help me resolve this.

Thanks & Regards,

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment