lunes, 12 de septiembre de 2011

RequestFactory in GWT 2.4

El codigo está disponible en GitHub usa GWT 2.4 y AppEngine 1.7.0
The code is available in GitHub using GWT 2.4 y AppEngine 1.7.0
https://github.com/poseidonjm/GAE-Simple
En un post anterior hice una demostración de RequestFactory con Objectify utilizando GWT 2.3 basándome en el blog de David M. Chandler. Pero cuando quise actualizar mi proyecto a GWT 2.4 versión disponible a la fecha ya no funcionaba. De acuerdo a RequestFactoryInterfaceValidation A partir de GWT 2.4 las Interfaces RequestFactory debe ser validadas antes de ser usadas por el código RequestFactory del server. Para lo cual necesita requestfactory-apt.jar que es el que realiza la validación. este jar lo descargue y lo puse en un directorio GWT_TOOLS/requestfactory-apt.jar
In a previous post I made an example with RequestFactory and Objectify using GWT 2.3 following the guide lines of David M. Chandler. But when I wanted to use GWT 2.4 my example didn't work. According  RequestFactoryInterfaceValidation starting with GWT 2.4, RequestFactory interfaces must be validated before they can be used by the RequestFactory server code. Then I download  requestfactory-apt.jar for validation and put in a directory GWT_TOOLS/requestfactory-apt.jar.

A continuación voy a actualizar ExampleRF de la versión GWT 2.3 a GWT 2.4
I am going to update ExampleRF from GWT 2.3 to GWT 2.4

Agregar el SDK de GWT 2.4 a Eclipse IDE
Add GWT 2.4 SDK in Eclipse

El GWT 2.4 lo pueden descargar aqui. Luego extraigo el zip.
Ahora para agregar un nuevo GWT SDK al Eclipse IDE hay que ir a Window->Preferences->Google->Web Toolkit
Download GWT 2.4 from here. Extract zip file. And for add a new GWT SDK in Eclipse IDE go to Window->Preferences->Google->Web Toolkit


Ahora descargo ExampleRF y lo extraigo en un directorio.
Download  ExampleRF and extract in a directory.

Ahora voy a Eclipse IDE e importo el proyecto. Hago click derecho en el explorador de proyectos y del menú contextual selecciono Import.
Open Eclipse IDE for import the project. Right click on package explorer in context menu. Select Import.
De la ventana Import selecciono Existing Projects Into Workspace y le doy Next.
In Import dialog select Existing Projects Into Workspace and click Next.

En la siguiente vista le doy click al botón Browse y busco el proyecto ExampleRF y le doy Finish.
In the next dialog click Browse, select ExampleRF and click Finish.

La versión que voy a utilizar ahora es GWT 2.4.
Hago click derecho en el proyecto y del menú contextual selecciono Properties. Luego en la ventana Properties voy a Google -> Web Toolkit
I will use GWT 2.4.
Right click on the project in context menu select Properties. In Properties dialog Google -> Web Toolkit.
Ahora voy a tratar de ejecutar el proyecto le doy click derecho y voy a Run As -> Web Application
y me muestra los siguientes errores.
En Console
I will try to run the project. Right click on the project and go to Run As -> Web Application. The Console output shows the following errors
[ERROR] Unexpected error
java.lang.RuntimeException: The RequestFactory ValidationTool must be run for the com.examplerf.shared.service.ExampleRFRequestFactory RequestFactory type
at com.google.web.bindery.requestfactory.vm.impl.Deobfuscator$Builder.load(Deobfuscator.java:59)
at com.google.web.bindery.requestfactory.server.ResolverServiceLayer.updateDeobfuscator(ResolverServiceLayer.java:43)
at com.google.web.bindery.requestfactory.server.ResolverServiceLayer.resolveRequestFactory(ResolverServiceLayer.java:176)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at com.google.web.bindery.requestfactory.server.ServiceLayerCache.getOrCache(ServiceLayerCache.java:233)
at com.google.web.bindery.requestfactory.server.ServiceLayerCache.resolveRequestFactory(ServiceLayerCache.java:198)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:207)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:127)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
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:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

y en el Development mode
Development mode output

17:24:37.530 [ERROR] [examplerf] Uncaught exception escaped
com.google.web.bindery.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:727)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$5.onTransportFailure(AbstractRequestContext.java:1104)
    at com.google.web.bindery.requestfactory.gwt.client.DefaultRequestTransport$1.onResponseReceived(DefaultRequestTransport.java:140)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Server Error 500 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 INTERNAL_SERVER_ERROR</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /gwtRequest. Reason:
<pre>    INTERNAL_SERVER_ERROR</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
</body>
</html>
    at com.google.web.bindery.requestfactory.shared.Receiver.onFailure(Receiver.java:44)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequest.onFail(AbstractRequest.java:118)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:707)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$5.onTransportFailure(AbstractRequestContext.java:1104)
    at com.google.web.bindery.requestfactory.gwt.client.DefaultRequestTransport$1.onResponseReceived(DefaultRequestTransport.java:140)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)



Ahora voy a configurar el requestfactory-apt.jar en Eclipse IDE.
Le doy click derecho al proyecto voy a Properties de la ventana siguiente voy a Java Compiler->Annotation Processing
I will configure requestfactory-apt.jar in Eclipse IDE. Right click on project in context menu select Properties and go to Java Compiler->Annotation Processing


Luego en Java Compiler->Annotation Processing->Factory Path agrego el requestfactory-apt.jar
Le doy al botón Add External JARS y agrego el jar.
Go to Java Compiler->Annotation Processing->Factory Path click on Add External JARS for add requestfactory-apt.jar

A los dos mensajes que aparecen a continuación les doy Yes.
In the following two dialogs, click on Yes

Cada vez que cambio el RequestContext debo hacer un rebuild al proyecto para revalidar
Everytime RequestContext is modified you need rebuild the project for revalidate

Selecciono el proyecto, Luego voy a Project->Clean...
Select the project, and go to Project->Clean...



Ahora voy a ejecutar el proyecto y ahora esta todo OK.
I run the project and everything is OK.




No hay comentarios:

Publicar un comentario en la entrada