Getting Started with GWT RequestFactory - google-app-engine

I'm new to GWT. I've manage to do the tutorial about how to build the simple StockWatcher application.
Now, I want to load the data from the server. After reading about the many different ways to do it in GWT I decide to use RequestFactory because apparently it the most affective way to write maintainable application.
The problem is that there is no tutorial about RequestFactory and Eclipse is hard enough to manage when you know if, it even harder to manage when I'm using a new tool like GWT.
I've manage to find the different jars required for RequestFactory like
gwt-servlet.jar
gwt-servlet-deps.jar
requestfactory-server.jar
Now I get the following error:
java.lang.RuntimeException: The RequestFactory ValidationTool must be run for the com.google.gwt.sample.stockwatcher.shared.service.StockWatcherRequestFactory RequestFactory type
I've even found a direction for this as well: RequestFactoryInterfaceValidation
but it's still not working.
I've add the com.google.web.bindery.requestfactory.apt.ValidationTool to my build path and it seem to help (the message was gone) but then I got different error message.
I've push the source to github repository.
Any help will be great.
I'll try to make a post once I'll manage to get this working so other can use it.
Thank you,
Ido.

I figure this out. object is not an instance of declaring class means that we try to invoke a instance method on object which is not of the type the method is declared on.
My mistake was that in my ServiceLocator implementation I mistakably return an instance of my domain model object (StockQuote) instead of the DAO (StockQuoteDao). This cause RequestFactory code to try and invoke StockQuoteDao.getNum method on StockQuote instance.
Ido.

If you are using google plugin for eclipse use this
http://vivagwt.blogspot.com/2011/09/requestfactory-en-gwt-24.html
you need rebuild you project every time you change you requestcontext
note: gwt-servlet.jar is needed if you use RPC

Also you may automatically run RequestFactory ValidationTool with maven in compiling phase:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-apt</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
</plugin>

Related

New Module connected with a Host App but Route to the module pages gives me a 404 error

I'm trying to get started with module development using Abp framework, the potential of using the framework is huge with the community and the abp.commercial support if it's needed, but it's not always easy to up and running the application. Let me explain...
I have created a new module: abp new sample.module -t module. ABP CLI version 3.3.1
After that, I have added a new entity in Domain (member.cs) and using AbpHelper.GUI to auto-generate all the code.
🎉My module works correctly using Hosts/*.web.unified test project. Well done! :).🎉
NOTE: see here if you want to know how to solve a tricky issue for me at this point.
Next, I have added assemblies one by one to the Host App. I have mapped:
Module.Application --> Host.Application
Module.Application.Contracts --> Host.Application.Contracts
Module.Domain --> Host.Domain
Module.Domain.Shared --> Host.Domain.Shared
Module.EntityFrameworkCore --> Host.EntityFrameworkCore
Module.HttpApi --> Host.HttpApi
Module.HttpApi.Client --> Host.HttpApi.Client
Module.Web --> Host.Web
Finally, I added Module Dependencies and Configurations, following this post.
🎉 Restore, build, dotnet ef migrations, and *.HostApp.DbMigrator work like a charm and the database is updated based on the entities in the module. Cool! 🎉
But... when I run my Host App and click on the new module menu contributor the route doesn't work 😒 but it seems to be correct based on the page structure of the module and it worked fine using Hosts/*.web.unified test project inside the module.
I tried several times with no lucky 🤦‍♂️
Something is missing in the code that I cannot see.
Any help is really appreciated.
Because the Host application and Module are in different solutions. I was missing to include an assembly (Module.Web.Views.dll) into the Host web project.

All of a sudden I have started getting error message from extent report. I am using Test NG and not maven

I configured extent reports (Selenium - TESTING) in my project and everything was working fine. I had tried to configure Maven but it failed, now extent reports were working fine and suddenly I have started getting below messages in eclipse console,
I tried to clean project, restart the system, update extent jar files, removing Maven related configurations, but nothing worked and still getting the below errors in console and my second iteration is not getting executed properly.
DEBUG 15341 [freemark] (): Couldn't find template in cache for "index.ftl"("en", UTF-8, parsed); will try to load it.
DEBUG 15341 [freemark] (): TemplateLoader. findTemplateSource("index_en.ftl"): Not found.
DEBUG 15341 [freemark] (): TemplateLoader.findTemplateSource("index.ftl"): Found.
DEBUG 15341 [freemark] (): Loading template for "index.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/a00/Downloads/selenium-java-3.13.0/jar_files(1) /extentreports-3.1.5.jar!/com/aventstack/extentreports/view/html-report /index.ftl".
and so on.
Set org.freemarker.loggerLibrary property to none as below
System.setProperty("org.freemarker.loggerLibrary", "none");
If you are moving to maven as a build tool make sure you have the dependencies for extent reports. Your stack trace is complaining about freemarker. Make sure you have these 3 dependencies in your POM file
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>

Groovy JsonBuilder classloading error in Wildfly-Camel 12

I am invoking JsonBuilder.toString() in Groovy code inside a Camel route. This Camel route runs inside Widlfly Camel 12.0. The code looks like so:
def builder = new JsonBuilder()
builder {
'myField': myFieldVal
}
return builder.toString()
The builder.toString() method invocation produces the following error:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class
groovy.json.internal.FastStringUtils
But I do have the dependencies mentioned properly in pom.xml like so:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<scope>provided</scope>
</dependency>
I also tried adding this extra dependency to resolve the problem:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>2.4.13</version>
</dependency>
But I still keep on getting the above exception. However when I run the same Camel code using the camel-maven-plugin, without deploying it inside Wildfly, it runs perfectly.
Can someone please help?
Thanks in advance.
I think the problem is that module org.apache.camel.script.groovy cannot access sun.misc.Unsafe. So I added the following module dependency to modules/system/layers/fuse/org/apache/camel/script/groovy/main/module.xml.
<module name="sun.jdk">
<imports>
<include path="sun/misc/Unsafe"/>
</imports>
</module>
Your example worked for me afterwards.

Jersey linking support with Google App Engine issue

I didn't manage to use the Jersey linking support with Google App Engine, I'm getting these exceptions when trying to access the application :
Caused by: javax.el.ELException: Could not find expression factory class
...
Caused by: java.lang.ClassNotFoundException: de.odysseus.el.ExpressionFactoryImpl
As specified in the documentation, I put this in the Jersey servlet section of the web.xml :
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.server.linking.LinkFilter</param-value>
</init-param>
I also add the jersey-server-linking-1.13.jar to the WEB-INF/lib directory of my project.
I tried to add el-api.jar first, then juel-2.1.0.jar to the WEB-INF/lib directory but I'm still getting these errors.
I'd like to know if someone could give me some hints about the way to deal with this. When I don't use the Jersey linking jar, everything is working as expected.
I had a similar problem with my GAE app. It was working fine with el-api and el-impl but started asking for de.odysseus.el.ExpressionFactoryImpl as development progressed. I made the switch but when I added JUEL to my pom.xml, I got the same error as John Prince (java.security.AccessControlException).
The solution for GAE users is to use JUEL 2.2.7.
At the time of this writing, 2.2.7 is not available in maven central. However, you can find it on
<repository>
<id>repo-id</id>
<name>repo-name</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
and link with whatever you need from
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-api</artifactId>
<version>2.2.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
<version>2.2.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-spi</artifactId>
<version>2.2.7-SNAPSHOT</version>
</dependen
Source: https://github.com/beckchr/juel/issues/73
The issue is due to de.odysseus.el.ExpressionFactoryImpl class not being found. I will assume that you have added the jars as you have mentioned to the WEB-INF\lib folder.
I would suggest that you view the JAR files via theProject Explorer , simple expand them in Eclipse and see if you can find the de.odysseus.el.ExpressionFactoryImpl class in ny of the JAR files that you have added.
I "solved" the problem by adding "juel" and "juel-impl" as dependencies of my project (we're using Maven; if you're doing it manually, you might have to figure out exactly what those projects contain).
However, as soon as I did that, I started getting a different exception:
java.security.AccessControlException: access denied (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_33\jre\lib\el.properties read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:289)
...
I'm pretty sure that's because it's running afoul of GAE restrictions.
I noticed in the original ClassNotFound exception it was trying to use the URLClassLoader; I'm also wondering if that problem was ultimately a GAE issue as well.
At this point, it seems like Jersey linking support isn't compatible with GAE.
This issue is (or rather was) due to a missing implementation of the Unified Expression Language. The EL API defines a static method that looks up an implementation of the ExpressionFactory class. There are various ways to define which implementation is to be used:
Use the Services API (as detailed in the JAR specification). If a resource with the name of META-INF/services/javax.el.ExpressionFactory exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class.
Use the properties file "lib/el.properties" in the JRE directory. If this file exists and it is readable by the java.util.Properties.load(InputStream) method, and it contains an entry whose key is "javax.el.ExpressionFactory", then the value of that entry is used as the name of the implementation class.
Use the javax.el.ExpressionFactory system property. If a system property with this name is defined, then its value is used as the name of the implementation class.
Use a platform default implementation.
(Source: http://docs.oracle.com/javaee/7/api/javax/el/ExpressionFactory.html#newInstance())
App Engine appears to have defined JUEL as default implementation but does not provide the respective packages.
In order to solve this, you need to (1) provide EL API and implementation packages and (2) use one of the above ways to link it. See https://stackoverflow.com/a/19814199/2099217 for details.

Google App Engine using maven

I've been trying to create a single project which can run both on sql and gae (where the 'datanucleus.properties' file needs to be changed) under a single maven folder structure. I first tried to get the Greeting example on the GAE website using mysql (this now works). Then, inspiring myself from beardedgeeks tutorial, I have tried to add the required dependencies so as to run the stuff on gae. By typing in mvn gae:run, however, I get the following error, posted at http://pastebin.com/fJ7c7xfx. I have spent a large amount of time searching google etc. for answers, but haven't been able to advance my case.
I would be glad to get some pointers.
Cheers,
manojo
This question is tagged [JDO] but the following trace:
Caused by: java.lang.ClassNotFoundException: javax.persistence.InheritanceType
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 77 more
suggests that you're missing the JPA API jar (provided by org.apache.geronimo.specs:geronimo-jpa_1.0_spec:1.1.1).
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_3.0_spec</artifactId>
<version>1.1.1</version>
</dependency>
Since you're not using JPA, you shouldn't have to do that but it appears that the JPA API is somehow referenced by the datanucleus appengine plugin as explained by #Datanucleus.
The people at Google unwisely put a reference in to that JPA class in their plugin and so it requires that you have the jpa.jar (the Geronimo one will do) in your CLASSPATH. An issue was raised on them a long time ago to fix it, but sadly they don't actively maintain their plugin.

Resources