Request factory in GWT, Library dependencies - java

I am newbie for GWT,and trying to understand the GWT request factory.
Moreover,I have been trying to run a Demo example of request factory from below link:
https://github.com/MikeMitterer/RFSample/
When I import it in Eclipse, there are so many libraries which are missing.
Like repackaged-appengine etc.
Can anyone help me to understand request factory. and why this libraries are required?

Heck that's the problem when you don't use managed dependencies (with tools such as Maven, Gradle or Ivy), you have to download everything by hand and edit the paths in the configuration to point to your downloaded JARs.
This sample apparently runs on AppEngine, so you'll have to download the Google AppEngine SDK. The author downloaded it (and the GWT SDK) separately, rather than using the Eclipse plugins from the Google Plugin for Eclipse. When done, edit the build path to fix the dependencies.
Back to Request Factory (rather than this sample), all you need is:
in your Build Path: gwt-user.jar if you're build a GWT app, or requestfactory-client.jar if you're building a Java app (such as an Android client), along with validation-api-1.0.0.GA.jar (and validation-api-1.0.0.GA-sources.jar if you're building a GWT app)
in your WEB-INF/lib: requestfactory-server.jar or gwt-servlet.jar, along with validation-api-1.0.0.GA.jar (you shouldn't need to add them to your build path though, all the classes they contain are already in gwt-user.jar); you might need gwt-servlet-deps.jar in addition to gwt-servlet.jar (can't remember, try it out)
if you want to use bean validation, also include Hibernate Validator in your `WEB-INF/lib, but it's optional.
Configure annotation processing with requestfactory-apt.jar, see https://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation
And some links to understand it:
http://www.gwtproject.org/doc/latest/DevGuideRequestFactory.html
http://blog.ltgt.net/gwt-211-requestfactory and http://blog.ltgt.net/gwt-211-requestfactory-part-ii
https://code.google.com/p/google-web-toolkit/wiki/RequestFactoryMovingParts

Related

Keycloak custom provider with Quarkus extension - where to put quarkiverse jars as dependencies?

I'm writing custom Keycloak provider which needs quarkus-cxf extension as a dependency to integrate with a SOAP service. Everything works well in the development mode (I use maven, so I needed to add quarkus-cxf as a dependency and run Keycloak on Quarkus from IDE using IDELauncher).
The problem starts when I'm trying to deploy my custom provider to the production environment. I know that my provider's jar need to be placed in providers directory within Keycloak distribution. Somewhere on Keycloak webpage I saw that every third-party dependencies jars I use, need to be placed in providers directory as well, so I did that and (thanks to maven-dependency-plugin) I generated all quarkus-cxf dependencies and put them all into providers directory. Then I tried to build keycloak by running ./kc.bat build and it failed with the message: ERROR: io.smallrye.config.SmallRyeConfigFactory: io.quarkus.runtime.configuration.QuarkusConfigFactory not a subtype.
How it should be done to work properly? I need CXF dependencies in the build phase because I generate code from WSDL file and it's necessary for Quarkus augmentation. Maybe not all dependencies from quarkus-cxf dependency hierarchy are needed here, but I cannot imagine developing and then adding one by one jar and check if it's enough for build or maybe not and I will get NoClassDefFound error :) I've got the same problem with my previous extension where I used resteasy dependencies but then only few jars were missing so I put them into providers directory and it worked. It's not the best solution for each and every one extension with extra dependencies like cxf (with huge hierarchy of transient dependencies).
Does anyone help me in this case? Maybe some of you have the same problem and you know how it should be done.

How to download Gradle dependency from java code?

My Java application needs to copy artifacts from Artifactory to AWS S3 temp bucket on demand (application group, name and version will be passed as parameters at runtime). The simplest way would be constructing URL and downloading files directly from Artifactory, but application should support 'latest.integration' and 'latest.relase' versions. So I want to add Gradle binaries to the classpath and use it to download dependencies.
Google results overflown with questions about dependency management using build.gradle.
So far I saw https://discuss.gradle.org/t/execute-gradle-task-from-java-code/21859/4 but looks like it also relies on preexisting build.gradle file.
So the question is: is there any way to use Gradle API from Java application to download certain lib without generating build.gradle file?
You should be able to use Ivy (http://ant.apache.org/ivy/) either as is or as a library itself to accomplish what you need, possibly with a bit of additional code.
(answer created from my comments)

Why I can't use a library in my Android project from Maven repository? How to write a correct pom.xml for this?

I want to use Jackson JSON parser library in my android project. I saw this library in Maven repository, but I don't know how to use it. I've downloaded sources from the Maven repository and Jackson jars and attached sources to jar, but in the logcat I saw error message NoClassDefFoundError. When googling I' ve read that I have to declare Jackson dependencies in pom.xml file.I' m a newbie in Java development so I don't know what all these means. And have some questions:
1.How to write pom.xml for the Jackson library
2.Where to put this pom.xml
3. Do I really need to install Maven if I just want to use the library.
4. What else I need to begin work with the library?
No, you do not need to write a pom file, unless you are using Maven for building (in which case you need it regardless of Jackson).
What you need are just Jackson jars -- there is more than one, since some projects only need some pieces. This page:
http://wiki.fasterxml.com/JacksonDownload
should show what you need, and where to get them from. If you are starting from scratch, I would strongly recommend using Jackson 2.1 (not 1.9). And then you most likely need 3 jars (jackson-annotations, jackson-databind, jackson-core) -- although minimal is just jackson-core, if you use so-called "streaming API" (low-level, highest performance, but more work).
The benefit of using Maven would be just that you can define logical depenendency (group and artifact id of jar), and Maven would resolve it to physical jar, as well as references to other jars.

Using (Scala) library from Java Web App, getting NoClassDefFoundError

I've been working on a rather "standard" Java web application for a long time now. I develop in Eclipse using Eclipse's server plugin to run the app in Tomcat. The app's setup is straight forward: Spring for bootstrapping, Wicket for web, Hibernate for ORM, Maven for dependency management.
Today I have added Akka 2.0 to the project. I added it to my POM as per the manual:
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor</artifactId>
<version>2.0.2</version>
</dependency>
Maven finds the dependency and I can see it showing up in the Maven dependencies in Eclipse's package explorer. The referenced Scala Library also shows up (version 2.9.2 as it seems).
I can use the library just as one would expect: Eclipse finds the classes, I can jump to source files etc. Everything works perfectly. But once I start the app and it comes across any part of the program with references to Akka it throws a NoClassDefFoundError.
Since all other libraries still work as expected, my best guess is that is has something to do with the fact that Akka is a library developed in Scala. Since I've hardly used Scala myself though, I could not find any solution to the issue myself and Google isn't really that helpful when it comes to such generic exceptions.
Do you have any advice?
Verify that the required library (AKKA) is in your deployment assembly under Eclipse: open the project's properties and look for "Deployment Assembly" on the left.
[I'm using Eclipse Indigo]
You could verify the presence (or lack) of the expected jar file by examining the deployment under tomcat.

maven gae plugin questions

I'm having some issues making the maven google app engine plugin work properly.
First of all, I'm not even sure if the archetype I'm using is the correct one, their examples show version 0.7.0 but it seems like never versions exist (i tried 0.9.1 and that works), where can I find a overview of what versions of the plugin is available?
Secondly, the archetype seems.. messy, I don't like the package structure and it doesn't seem to actually include the GAE and GWT dependencies. I have to manually add them to my project in Eclipse, which kind of defeats the purpose of using maven. And how come they are breaking the gwt maven plugin? I know that one includes the actual gwt jars as maven dependencies?
I'm fairly new to Maven, but I have been using the gwt maven plugin for a while, and I'm very happy with everything about it. Is there any way I could just their archetype to do the base project and add the gae plugin to it?
UPDATE
I suspect the problem I'm seeing with the GAE maven plug-in is in regards to undefined properties in the POM. I have no idea if its due to error these aren't set-up or if its due to me actually have to manually set them up. The documentation on this plugin is sparse.
Thanks for the answer below, but I really don't want to add another archetype into play. I think the best solution for me is to try and adapt a GWT maven project manually, to include support for GAE.
I've used the archetype like so :
http://code.google.com/p/gae-mvn-archetype/
to generate a GAE project template.Then manually added my other dependencies. This got me a usable project which I can deploy to GAE and everything.
Also, for Eclipse importing, once the template project was done, I've imported it into eclipse using the m2_eclipse plugin :
http://m2eclipse.sonatype.org/installing-m2eclipse.html
(note that i've imported it into Eclipse as a Maven project, NOT as an Eclipse whatever project)
This imported the thing into eclipse with all the necessary dependencies and without errors.

Categories