PDA

View Full Version : IncompatibleRemoteServiceException for 'BasePagingLoadConfig' in grid pagination



nchopade
16 Jul 2009, 3:40 PM
Hi,

I am getting the error below while trying paging example of ext gwt 2.0(http://extjs.com/examples/#paging). The example works fine as is in gxt 1.7.

But if I use in spring framework, it throws the error.

I use class GWTController to delegate work to the spring injected service. I have copied my code after the error message below.

Has anyone faced this problem or know the solution?

Your help to resolve this problem would be highly appreciated.(I already tried rebuilding after removing entire output/gwt files, also tried with and wihout hosted mode - but still get the same error.)

Error
An IncompatibleRemoteServiceException was thrown while processing this call.
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: Type 'com.extjs.gxt.ui.client.data.BasePagingLoadConfig' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer. For security purposes, this type will not be deserialized.
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:298)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:164)
at com.barcap.lca.server.GWTController.processCall(GWTController.java:55)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
at com.barcap.lca.server.GWTController.handleRequest(GWTController.java:47)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.ru
(QueuedThreadPool.java:488)


spring-servlet.xml
-----

<

bean name="GreetServiceController"

class="com.barcap.lca.server.GWTController"><property name="remoteService"><bean class="com.barcap.lca.server.GreetingServiceImpl"></bean></property></bean>


<bean id="urlMapping"class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><property name="mappings"><value>
/**/testGrid.rpc=GreetServiceController
</value></property></bean>
----


GWTController
package com.barcap.lca.server;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.server.rpc.RPC;
import com.google.gwt.user.server.rpc.RPCRequest;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class GWTController extends RemoteServiceServlet implements Controller,
ServletContextAware {
/**
*
*/
private static final long serialVersionUID = 396117982145294562L;
public static HttpServletRequest request;
public static HttpServletResponse response;
private ServletContext servletContext;
private RemoteService remoteService;
private Class remoteServiceClass;

public ServletContext getServletContext() {
return this.servletContext;
}
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
GWTController.request = request;
GWTController.response = response;
super.doPost(request, response);
return null;
}

public String processCall(String payload) throws SerializationException {
try {
RPCRequest rpcRequest = RPC.decodeRequest(payload,
this.remoteServiceClass);
// delegate work to the spring injected service
return RPC.invokeAndEncodeResponse(this.remoteService, rpcRequest
.getMethod(), rpcRequest.getParameters());
} catch (IncompatibleRemoteServiceException ex) {
getServletContext().log("An IncompatibleRemoteServiceException was thrown while processing this call.",ex);
return RPC.encodeResponseForFailure(null, ex);
}

}
public void setRemoteService( RemoteService remoteService )
{
this.remoteService = remoteService;
this.remoteServiceClass = this.remoteService.getClass();
}
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
}

onModuleLoad method in my entry class


publicvoid onModuleLoad() {



ServiceDefTarget endpoint = (ServiceDefTarget) greetingService;
String moduleRelativeURL = GWT.getModuleBaseURL() + "testGrid.rpc";
endpoint.setServiceEntryPoint(moduleRelativeURL);
Registry.register(AppConstants.GREET_GENERIC, greetingService);


final GreetingServiceAsync service = (GreetingServiceAsync) Registry.get(AppConstants.GREET_GENERIC);


RpcProxy<PagingLoadResult<Post>> proxy = new RpcProxy<PagingLoadResult<Post>>() {
@Override
publicvoid load(Object loadConfig, AsyncCallback<PagingLoadResult<Post>> callback) {
service.getPosts((PagingLoadConfig)loadConfig, callback);
}
};


// loader final PagingLoader<PagingLoadResult<ModelData>> loader = new BasePagingLoader<PagingLoadResult<ModelData>>(
proxy);
GWT.log("loader"+loader.getLimit()+"---"+loader.toString(),null);
loader.setRemoteSort(true);


ListStore<Post> store = new ListStore<Post>(loader);


final PagingToolBar toolBar = new PagingToolBar(50);
toolBar.bind(loader);


List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("forum", "Forum", 150));
columns.add(new ColumnConfig("username", "Username", 100));
columns.add(new ColumnConfig("subject", "Subject", 200));
ColumnConfig date = new ColumnConfig("date", "Date", 100);
date.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));
columns.add(date);


ColumnModel cm = new ColumnModel(columns);


final Grid<Post> grid = new Grid<Post>(store, cm);
grid.setStateId("pagingGridExample");
grid.setStateful(true);
grid.addListener(Events.Attach, new Listener<GridEvent<Post>>() {
publicvoid handleEvent(GridEvent<Post> be) {


PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(50);


Map<String, Object> state = grid.getState();


if (state.containsKey("offset")) {
int offset = (Integer)state.get("offset");
int limit = (Integer)state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
if (state.containsKey("sortField")) {
config.setSortField((String)state.get("sortField"));
config.setSortDir(SortDir.valueOf((String)state.get("sortDir")));
}
}
});



grid.setLoadMask(


true);

grid.setBorders(true);
grid.setAutoExpandColumn("forum");
grid.setBorders(true);


ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
//panel.setIcon(Examples.ICONS.table()); panel.setHeading(


"Paging Grid");

panel.setLayout(new FitLayout());
panel.add(grid);
panel.setSize(600, 350);
panel.setBottomComponent(toolBar);
RootPanel.get().add(panel);


service -


public


interface GreetingService extends RemoteService {

String greetServer(String name);


public PagingLoadResult<Post> getPosts(PagingLoadConfig config);


//public PagingLoadResult<Post> getPosts();public PagingLoadResult<BeanPost> getBeanPosts(PagingLoadConfig config);
}


The implemenation is same from ExampleServiceImpl.java of ext gwt 2.0 examples.