I just installed the Google Eclipse plugin and created my first test Web Application Project (using both GWT and GAE SDKs). The plugin autogenerated a project that had a war/ directory in it that had some peculiar subdirectories and files in it. An online search for many of these only returned other similar autogenerations of them but without any real explanation of what they are, or what they do:
war/WEB-INF/deploy/<myapp>/rpcPolicyManifest/**
war/WEB-INF/deploy/<myapp>/symbolMaps/**
war/<myapp>/symbolmanifest.json
gwt-unitCache/**
I'm also a litte confused about what the proper structure should be for a GWT WAR that is going to be deployed to GAE. What content should be packaged under war/WEB-INF/? What content should be packaged under the war/ root? Any other special considerations for GWT/GAE WARs? Thanks in advance!
Almost everything in the war/ folder is deployed to GAE. With the exception of temp-files that are used by the plugin, such as war/WEB-INF/appengine-generated/
The war/WEB-INF/ folder contains things needed to set up the GAE. This includes GAE settings for servlets, queues, logging, RPC etc. It also includes libraries that are used server-side and some GWT-mappings.
Note that the GWT libraries only are needed at compile-time and not on the server. You can put all GWT libraries in a lib/ folder outside of war/.
war/WEB-INF/deploy/<myapp>/rpcPolicyManifest/**
RPC is used to call server-methods directly from GWT-code. GWT/GAE is designed to allow RPC out-of-the-box. My guess is that the existence of a RPC policy manifest file is enough to configure GAE to allow the GWT code to use RPC, so they just put it there so you don't have to worry about it.
war/WEB-INF/deploy/<myapp>/symbolMaps/**
The plugin automatically adds the things needed here, so you don't have touch it. But the symbolMaps appear to be a dictionary used by GWT to supply different version of the app based on browser version. The first few lines in one of my symbolMap files read like this:
# { 1 }
# { 'user.agent' : 'gecko1_8' }
# jsName, jsniIdent, className, memberName, sourceUri, sourceLine
Duration,,com.google.gwt.core.client.Duration,,jar:file:/opt/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201208080121-rel-r42/gwt-2.4.0/gwt-user.jar!/com/google/gwt/core/client/Duration.java,21
Which specifies how the JavaScript symbol 'Duration' should be interpreted, given that the user agent is gecko 1.8. Each browser-compilation (FF, Opera, Safari, IE etc.) has it's own mapping, allowing for browser-specific optimizations by the GWT compiler.
war/<myapp>/symbolmanifest.json
I don't have this file in my project, but it's probably related to the GWT symbol maps mentioned above. My guess is that it defines the JavaScript symbols that the GWT app uses. If you post a snippet from it we'll be able to see if this is the case.
gwt-unitCache/**
This is a cache-folder that is only used during development. See the release notes for GWT 2.4.0:
Persistent Unit Cache: GWT Compiler and Development mode now cache
compilation artifacts between runs. This results in faster startup
time for iterative development.
Related
Everybody in the world, except me, seems to know what exactly the "Dynamic Web Module" facet is adding to a project. Web search reveals tons of responses how to recover from various errors originating in more or less unwanted changes in the version of this facet, but there is hardly any information about what the facet actually does.
So my questions are:
What exactly does the "Dynamic Web Module" facet add to my eclipse project?
Why should I want this to happen?
Why do my colleagues using IntelliJ, Visual Studio Code etc. –where this concept does not seem to exist– have no problem?
Keeping mind that I didn't decide on these names (and I grumbled about them myself at the time)... The term dates back to the early J2EE Tutorials, like https://docs.oracle.com/cd/E17802_01/j2ee/j2ee/1.4/docs/tutorial-update2/doc/WebApp3.html The tutorial would explain that J2EE web modules are the web applications from the then Java Servlet specification. J2EE loved to subsume the other specs and use its own naming for things that already had names. The doc and tools often followed suit.
It also mentions that they can contain static web resources, and in fact you can run web modules that only contain static resources. So WTP has the concept of a static web module and a dynamic web module, as static web projects and dynamic web projects in Eclipse. The Facet designates a project as being one of the two, and for dynamic modules, which API level it supports and requires at runtime.
Server adapters then have to state which API versions the server types they provide can support. The Server Tools and validation can then help you avoid deploying to an incompatible server, as well as build against a valid server. You want to build against a valid server in the same way you want to compile against your intended Java runtime. It's the most straightforward way to, for example, avoid calling classes and methods that didn't exist at the time.
There's also a Module Core nature that gets added, which supports APIs for describing the deployment details. Details like saying your Java class output folder contents go into WEB-INF/classes, that the jars you select go into WEB-INF/lib and that those static resources go into the application root, all to comply with the layout expected at runtime. That API is meant to be pluggable, so it can be fulfilled by e.g. Maven integration.
The terms in the UI can be changed, but that has its own pain points. The community tends not to update old videos and tutorials that have been correct for years.
I want to setup GWT in a special mode. I only use GWT for the client side as a replacement for having to deal with JavaScript directly.
The idea is to produce a single JS file.
Since this is also part of a bigger project with multiple project pages I got a problem where to put the output of the compiler and how to setup.
The ideal setup would be placing the GWT stuff into a single project and incooperate the ouput in a different project. The question is how to do it?
Update:
The current plan is to compile the JavaScript out of GWT using a simple Java application just issuing the GWT compile command and taking the Eclipse auto-build classes as necessary input. After the sources are compiled to java script the application copies the js files (one for every supported browser) to the related destination. This way the once created js files stay static and other developers do not have to deal with GWT related build tasks and we just avoid a necessary maven fight to get things working on build.
Also the GWT project can now depend on the web project making it possible to start the web application and alter its behaviour by adding support to host mode debugging.
Does anyone know a working example?
The easiest way, if you build a WAR in the end, is to put the output of GWT in a WAR too that you can use an an overlay in the final WAR module.
Other Maven plugins could do the trick too (dependency:unpack, maven-shade-plugin, etc.)
See https://github.com/tbroyer/gwt-maven-archetypes for examples.
I am developing a WebSphere portlet in IDEA 11. The portlet is using some methods defined on portal. I don't have the production environment compiled classes or jars on my PC but I have the source code.
Can I somehow "attach" the .java files to my projects in order to build a war file that will be deployed into the production environment? Or do I have to build the production sources first (this seems to be harder since there are lots of dependencies)?
If this is just to test something while you await the JARs/compiled classes, you can likely do this by only bringing over the API (e.g., referenced interfaces that hopefully don't have external dependencies). Then, open up the compiled WAR and remove those .class files manually to avoid collisions with the real code on the server.
The biggest problem is that you will definitely run into issues trying to limit the exposure to the real code, unless the rest of the code was setup nicely to expose an API that has very limited dependencies.
Is it possible to use the Guava libraries on a project done with both GWT and Google AppEngine?
I see that the individual jars (the standard Java one and the GWT compatible one) have the same package naming hierarchy. How do these integrate in a GWT+AppEngine projecT?
Yes it is possible. A few Guava classes won't be usable on AppEngine because of the restricted sandbox your app will run in, especially those in the .io package like Files (you will be able to read stuff but not write it).
Are you worried about deploying both jar files and having a conflict? If so, I think it will be fine - when you compile your GWT application, it turns into javascript, so you wouldn't necessarily be deploying the GWT compatible jar, just the normal one.
There won't be any conflict as the gwt one will be used by true DevMode client-side and the GWT compiler, the "normal " one will live in your WEB-INF/lib and be loaded (in DevMode) in a different classloader. It thus depends entirely on your project and build setup.
That being said I never tried it within the same Eclipse project. I always use distinct client and server projects, and -noserver in DevMode.
After getting counterclockwise working on my Eclipse setup
and GAE development server running in interactive mode I found these
things still unclear for me:
1) How can I start server and application without commanding it on
REPL?
2) When I deploy application to Google servers, how and where do I
define the entry point of application? I mean, how Google will know
which application, application handlers and routes to use?
3) Can I combine using java classes and clojure files on same project
so that both are compiled automatic when creating and editing them on
my src folder?
4) Which files and jars are actually needed for uploading to GAE at
the end? Im used to deploy PHP apps to GAE, but here I dont know if I should make jars, include compiled clj files. I also might like to organize files different way than counterclockwise or appengine-magic does, so where do I specify paths to resources and classes?
5) Finally is it possible to connect Google production server with
Emacs - Slime - Swank combination? That would be the fulfill of
dreams, lol.
I'm using appengine-magic with Jetty, Compojure, Ring and Hiccup.
I'm going to suggest a lein/appengine-magic/Eclipse hybrid approach. Create your GAE project with appengine-magic and then set it up in Eclipse.
Create a Clojure "Run Configuration" and check the source files you need evaluated to bring the server up. You will get a REPL to it when it starts.
Your GAE entry point is your web.xml server-class, which refers to the ahead-of-time compiled source in app_servlet.clj (assuming you used lein appengine-new to create the project originally). Look in app_servlet.clj for the call to make-servlet-service-method -- the argument there is your App Engine Magic (see def-appengine-app in core.clj) entry point. In turn that refers to your Compojure handler and routes. See https://github.com/gcv/appengine-magic for the details.
I have not done this, so cannot comment.
Let appengine-magic take care of this: lein appengine-magic prepare, then deploy the deploy the war directory appcfg.sh (which you can find in the GAE Java SDK). You may also be able to use the GAE Eclipse plugins to achieve this.
You cannot use sockets with GAE. Swank depends on sockets, so a REPL to your live application is not possible. You can REPL all you like with the dev server however.
Q 1 & 2 were eventually solved and cleared.
Q 3 I wasnt able to do it because either java or clojure classes overwrote each other and I couldnt change target directories for them separately.
Q 4 after first succesfull deployment now I know what are the core base jars to be included. Yes it depends on what you happen to use on your project. I think I have transferred way too many unnecessary files on PHP deployments.
Q 5 Thats what I thought. But I didnt get swank working on dev app engine server. Its reporting illegal access to some appengine sdk file. Maybe I need to include it on project libs...