问题描述
这个是浏览器端GWT中的方法,想根据用户填写的ID查询出结果:publicclassPro_hibernate_gwtimplementsEntryPoint{//FindByIdVerticalPanelmainID=newVerticalPanel();finalFlexTablelbID=newFlexTable();mainID.add(lbID);RootPanel.get().add(mainID);ButtonbtnFindById=newButton("FindByIDUser");finalTextBoxtextBoxFindByID=newTextBox();btnFindById.addClickHandler(newClickHandler(){publicvoidonClick(ClickEventevent){//TODOAuto-generatedmethodstubUserInfoServiceAsyncuserinfoService=GWT.create(UserInfoService.class);userinfoService.findUserInfoById(Integer.parseInt(textBoxFindByID.getText()),newAsyncCallback<UserInfo>(){@OverridepublicvoidonFailure(Throwablecaught){//TODOAuto-generatedmethodstub}@OverridepublicvoidonSuccess(UserInforesult){//TODOAuto-generatedmethodstubUserInfouserByidObject=result;lbID.setText(0,1,userByidObject.getUserId()+"");lbID.setText(0,2,userByidObject.getUserName());lbID.setText(0,3,userByidObject.getUserAddress());Window.alert(userByidObject.getUserId()+"");}});}});RootPanel.get().add(textBoxFindByID);RootPanel.get().add(btnFindById);下面是服务器端的代码:publicclassUserInfoServiceImplextendsRemoteServiceServletimplementsUserInfoService{/***selectbyid*/publicUserInfofindUserInfoById(intid){Sessionsession=HibernateTools.getSession();try{session.beginTransaction();UserInfouserinfo=(UserInfo)session.load(UserInfo.class,id);session.getTransaction().commit();returnuserinfo;}catch(Exceptione){session.getTransaction().rollback();e.printStackTrace();}returnnull;}}Debug状态下运行不进入断点调试状态,显示如下错误:tartingJettyonport8888[WARN]ExceptionwhiledispatchingincomingRPCcallcom.google.gwt.user.client.rpc.SerializationException:Type'com.ming.client.mapping.UserInfo$$EnhancerByCGLIB$$d279e941'wasnotincludedinthesetoftypeswhichcanbeserializedbythisSerializationPolicyoritsClassobjectcouldnotbeloaded.Forsecuritypurposes,thistypewillnotbeserialized.:instance=com.ming.client.mapping.UserInfo@dfe01catcom.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:614)atcom.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)atcom.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)atcom.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)atcom.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:609)atcom.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:467)atcom.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:564)atcom.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:207)atcom.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243)atcom.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:637)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:717)atorg.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)atorg.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)atorg.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)atorg.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)atorg.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)atorg.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)atorg.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)atorg.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)atorg.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)atorg.mortbay.jetty.Server.handle(Server.java:324)atorg.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)atorg.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)atorg.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)atorg.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)atorg.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)atorg.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)atorg.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)[ERROR]500-POST/pro_hibernate_gwt/userinfo(127.0.0.1)57bytes请大侠们指教小弟了
解决方案
解决方案二:
Type'com.ming.client.mapping.UserInfo$$EnhancerByCGLIB$$d279e941'wasnotincluded提示:notincluded没定义,你看看是没定义还是路径问题了,希望对你有帮助
解决方案三:
看到这个:[WARN]ExceptionwhiledispatchingincomingRPCcallcom.google.gwt.user.client.rpc.SerializationException:Type'com.ming.client.mapping.UserInfo$$EnhancerByCGLIB$$d279e941'wasnotincludedinthesetoftypeswhichcanbeserializedbythisSerializationPolicyoritsClassobjectcouldnotbeloaded看看你的客户端UserInfo里是不是定义的EnhancerByCGLIB和服务器端UserInfo不同