|
RequestFactoryInterfaceValidation
Provides late validation of RequestFactory interfaces
Starting with GWT 2.4, RequestFactory interfaces must be validated before they can be used by the RequestFactory server code or JVM-based clients. This document explains the mechanisms for validating those interfaces. OverviewERRATA This page incorrectly guides you to find requestfactory-apt.jar in the GWT_TOOLS directory. Instead, Developers should find the requestfactory-apt.jar that came with their distribution. GWT contributors should use the appropriately dated jar in GWT_TOOLS (at this writing requestfactory-apt-2011-08-18.jar), or build their own via ant requestfactory. Note also that the screen shots are aimed at GWT contributors. The RequestFactory annotation processor will validate the RequestFactory interface declarations and ensure that the mapping of proxy properties and context methods to their domain types is valid. The manner in which the errors are reported depends on the method by which the annotation processor is invoked. In addition to validating the interfaces, the annotation processor also generates additional Java types which embed pre-computed metadata that is required by the RequestFactory server components. Users of RequestFactorySource must also run the annotation processor in order to provide the client code with obfuscated type token mappings. In the client-only case, the server domain types are not required. If the validation process is not completed, a runtime error message will be generated: The RequestFactory ValidationTool must be run for the com.example.shared.MyRequestFactory RequestFactory type Annotation ProcessorIt most convenient for both the shared RequestFactory interfaces and their server domain counterparts to be available on the sourcepath or classpath during the compilation process. If this is not practical, see the ValidationTool section for information on post-processing pre-compiled shared interfaces and domain types as part of a deployment process. javac buildsUsers using javac to compile their entire project at once need only to include the requestfactory-apt.jar on the build classpath. The compiler will automatically load the annotation processor from the JAR file. The shared proxy interfaces must be included in the list of java files being compiled. IDE configurationEclipseOpen the project properties dialog and navigate to Java Compiler -> Annotation Processing. Ensure that annotation processing is enabled -- by default it is not.
Add the requestfactory-apt.jar to the factory path.
The project will need to be rebuilt, but once this is done, any RequestFactory validation errors or warnings will be displayed in the editor upon saving:
ValidationToolNot all build processes are amenable to compiling the shared proxy interfaces and the domain types at the same time. Cases where the ProxyForName and ServiceName annotation are used are typical of this build configuration. In these cases, it is possible to post-process pre-compiled shared and domain types using the RequestFactory ValidationTool. To run the ValidationTool it is necessary to have the shared interfaces and domain types available on the classpath. The binary names of the RequestFactory interfaces are provided to the tool as well as an output location, which may be a directory or a jar file. The tool will produce one or more class files that contain precomputed metadata that will be used by the RequestFactory server code. #!/bin/sh java \ -cp requestfactory-apt.jar:requestfactory-server.jar:your-shared-classes.jar:your-server-classes.jar \ com.google.web.bindery.requestfactory.apt.ValidationTool \ /path/to/output.jar \ com.example.shared.MyRequestFactory \ com.example.shared.AnotherRequestFactory An optional client-only mode will produce the metadata required by RequestFactorySource clients using only the shared interfaces. This mode is activated by adding a -client flag before the output location. Maven buildsUse the following recipe to run the ValidationTool. If you are using Maven with Google Plugin for Eclipse (see WorkingWithMaven), you do not need to configure Eclipse with the requestfactory-apt.jar as described above. The ValidationTool will be invoked via the POM instead. <!-- requestfactory-apt runs an annotation processor (APT) to
instrument its service interfaces so that
RequestFactoryServer can decode client requests. Normally
you would just have a dependency on requestfactory-apt
with <scope>provided</scope>, but that won't work in
eclipse due to m2e bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=335036 -->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-apt</artifactId>
<version>${gwtVersion}</version>
</dependency>
</dependencies>
</plugin>
<!-- Google Plugin for Eclipse (GPE) won't see the source
generated above by requestfactory-apt unless it is exposed
as an additional source dir-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/apt</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>In order for the build-helper-maven-plugin to work, you must also install the buildhelper connector. This should happen automatically when you import a project that requires it. If not, you'll see an error in the POM. To install it, go to Window > Preferences > Discovery > Open Catalog and install the buildhelper connector, then re-import the project from scratch. In Eclipse 3.7 (Indigo), the following additional POM snippet is needed:
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<versionRange>[2.0.5,)</versionRange>
<goals>
<goal>process</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
|
IDE configuration for Intellij IDEA: http://goo.gl/6P6dT
someone's using netbeans ?
Unable to initialize a JSR 303 Bean Validator javax.validation.ValidationException?: Unable to find a default provider ???
If you don't include a jsr-303 validator, then you'll get this WARNING.
If you want it to go away, you can include the hibernate validator of versions greater than or equal to 4. I'm unaware of any other 303 bean validators out there.
Or you could just swallow the WARNING aswell.
Ty for this ~
Hello, Can anyone help me ?
I import a example project from the svn site : http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/dynatablerf/ .
and I try to configure my gwt-maven-plugin and eclipse environment to run the project.
after that , I build this project and got errors :
error on execute: null
Build errors for dynatablerf; org.apache.maven.lifecycle.LifecycleExecutionException?: Failed to execute goal org.bsc.maven:maven-processor-plugin:2.0.5:process (process) on project DynaTableRf?: Error executing
My notes on building a demo and the validator .sh here: http://code.google.com/p/gwt-examples/wiki/DemoRequestFactory
I have got the same problem "error on execute: null "
I get the same error with eclipse Indigo but it seams to work fine with helios
I couldn't find where to do this. To set this up, Right click on project goto properties.
I was unable to use these tips in Eclipse Indigo (3.7) for my App Engine Connected Android Project. Does anyone have other tips?
I also have problems with my App Engine Connected Android Project on both eclipse 3.6, 3.7, only for the android part. When I change the annotation processing verbose parameter to true, i get "no domain mapping" warning while compiling. I have added the requestfactory-apt.jar in the annotation processing in both the Android and the Appengine/GWT project. I would appreciate if someone gave tips how to fix the android project.
I searched for hours why it doesn't process annotations in eclipse. Very important to change JDK Compliance to 1.6, it was set automatically set in my case to 1.5. Maybe add this as a note.
I have problems to get this work in combination with Grails. The methods defined in my own RequestContext? should be resolved dynamically at runtime. I.e. in Grails every domain object has a save and delete method attached to the domain object at runtime. Hence, these methods cannot be discovered in compile time.
Does anyone have an idea?
Answer my own question: Annotate the appropriate interfaces with @SkipInterfaceValidation? to suppress compilation errors due to missing methods aso.
Very difficult to understand. "Use the following recipe to run the ValidationTool?." and then it gives some XML code. No idea where this code should go.
Let me see if I understood, to use the validation tool you must:
Make available both the shared RequestFactory? interfaces and their server domain counterparts on the sourcepath or classpath during the compilation process.--Can you please explain how to do this .
If this is not practical then use the validation tool which consists in :
#!/bin/sh java \
--Can you please explain how to do this, is it done in cmd or in a property en eclipse ?
Are these two different solutions? or are both tasks supposed to be implemented.
Thank You very much
After doing this, I'm still getting this error... and cant continue my work... does anyone knows how to solve it? "Caused by: java.lang.ClassFormatError?: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation"
This is really frustrating. I've got a Android Engine Connected Project I'm trying to build using GWT2.4 RequestFactory? and Objectify on my Eclipse IDE.
Apparently I need to use the Validation Tool because there's no way I can have my domain classes on the server side camping in my android package. The problem is the example on this page really isn't very helpful.
Since I never worked on Unix, it took a while to figure out what the script was and what it apparently works.
So I tried running the validation tool from the windows command line, but get the following error: "This tool must be run with a JDK, not a JRE"
WTF??
There's gotta be a better way!
RequestFactory? is causing me nothing but headache.
For the one who is unable to find Annotion Processing in Java Compiler item in Eclipse Indigo, just download WTP from http://download.eclipse.org/webtools/repository/indigo/
If you have an "error on execute: null" when launch "update maven configuration" probably its because you are using maven with JRE but you need JDK.
Add something like this in your eclipse.ini file! -vm C:/dev/jdk1.6.0_29/bin
This tool keep yacking when I use generics!
How do I get that to work?
For those who met following message: [RuntimeException: The RequestFactory? ValidationTool? must be run for the ... ] running "App Engine connected Android project" sample on Eclipse Indigo, AppEnging? 1.6.4 without Maven. There is possible solution (worked in my case). Click YouProject?-Android > Properties > JavaBuildPath? > OrderAndExport? Tab > Check on all .jars. Same do in YourPeroject?-AppEngine?. (spent allll day installing Maven staff and googling other solutions but finally noticed unchecked jars mentioned above, checked on and TA-DAa:)
I see you've updated this, nice work Thomas.
It may be worth noting for those that do not use m2e:
Don't include maven-processor-plugin, and instead do what the comments say (include the requestfactory-apt as a dependency). For me, that plugin causes my gwt to go through the compile every time, even when nothing's changed. Removing that processor block still gives me good builds, and better yet, gwt doesn't compile when nothing's changed.
When I try to validate Request Factory, I am getting the following error.
my build.xml for validate looks like this.
Please help, Thanks in Advance.