GWT/Grails Project Structure - gwt

Does somebody already have some experience embedding gwt in other
client pages except the standard html file?
I want to use gwt as front end and grails as backend. Communication
should be handled over rest json interface so that is loosely coupled.
How do i structure my project at best? Should I create 2 independend
projects or should I stick them together?
At the beginning I had some problems with debugging my gwt application
as it was part of the grails project. Now I copied the compiled js
script to my webapp folder and included it in a grails page. Debugging
gwt in noserver mode worked ok. The problem is , how do I solve my
deployment later at best as I dont want to copy my js everytime by
hand? Already tried the grails gwt plugin but its difficult to debug the gwt application and I even do not want to use the service stuff provided with the plugin.
I thought its a good idea to have 2 maven modules on for grails and one for gwt. Later 2 war files(one grails, one gwt) will deployed on Tomcat, so I also can change gwt client stuff without deploying grails again. How do i manage the brige from grails to gwt best? Just call the standard html in a div from grails page?
I am using maven for building my project.
Thanks for all your help

I have written 2 posts about this topic. In the first one I show Grails+GWT in the same application, using the Grails Gwt Plugin. It appears you already tried that approach. In the second post, I show how to do it with 2 seperate applications, talking JSON between each other using RequestBuilder to request the grails app (that serves JSON responses).
For The deployment in production, you should have Maven doing this job for you.

Related

I get "Can't find any GWT Modules on this page"

I am trying to set up my eclipse with gwt and after I installed Jdk 8 and eclipse 2019-06 and gwt eclipse plugin 3.0 I created the sample project with code generated and when I try to run the sample code in GWT Development mode it gives me url http://localhost:9876 and when I open it I get "Can't find any GWT Modules on this page" Can you please help why It is giving me Can't find any GWT Modules on this page. I am assuming if I am running it in development mode I don't need to set up web server so I didn't. I didn't used gwt for long time and I am lost why it is giving me this can't find gwt module message when I load the page. Can you please help?
You still need a server, if you want to run any java code on your server. Such as code for talking to your database.
Gwt only does 2 things:
1: is is handling the client side, where it generate javascript from your java code.
2: It includes a .jar file, which can be used together with a java servlet server such as apache tomcat to serialize java objects which can then be send between the client and the server. And this .jar file will serialize all needed objects. And gwt will generate the needed javascript code.
Gwt does not itself include any http server. The address http://localhost:9876 is only used to configure gwt. It is just a page with 2 buttons to turn dev mode on/off.
The eclipse plugin does include a embeded webserver which can be used for gwt development. I have newer done this and I think that installing an independent java tomcat server is the best solution.
But if you want to use the eclipse embeded webserver you need the "Run in development mode with Jetty." - Jetty is the name of the embeded java servlet server.
Are you using the plugin from Google ?
If so, this is outdated. I advice you to use the plugin from branflake. You can find this plugin on GitHub : https://github.com/gwt-plugins/gwt-eclipse-plugin
Also on that GitHub page a lot of documentation is available. Like a link to a very helpfull YouTube playlist: https://www.youtube.com/watch?v=DU7ZQVLR5Zo&list=PLBbgqtDgdc_TqzA-qXrjgTFMC_6DKAQyT
My advice is to watch these YouTube videos to get you started. If you follow them all should be working without a problem.
I haven't used this plugin for a while since I switched to IntelliJ. But I did use it in GWT2.8.2 so it should still work fine.

difficulty in deploying struts 2 application

I am a beginner with struts2 and I have few struts2 projects downloaded from a website, but they all are created as simple java projects and not as web-projects, so I am unable to deploy them on my Tomcat or JBoss AS server through Eclipse.
How can simple java projects be deployed on a Java EE server?
Your best bet is download sample applications from Struts2 official sites and deploy them on any of the server of your choice.
Those sample application comes with all required dependencies as well will give you idea about structuring of S2 application as well flow and configurations
I created a structure similar to the one shown on website and manually added all the files required and it worked.

how to integrate Spring and GWT from 2 different projects

I am tying to integrate a gwt project with my already running spring project.
i am using eclispe, and i have a Spring MVC application that receives JSON requests.
i am using the built in Tomcat to run my MVC application.
now i would like to create a new GWT project and have it communicate with my spring project with JSON.
i understand that they need to run on the same ip and port so i would not have to make cross site communication.
if i try to run my GWT application as run-as->Web application (which is the normal way for the project) on the same port as the Tomcat server i get an error that the address is already in use (which makes sense)
i tried creating a new dynamic web project and make it look the same as the GWT project. even though i am able to run the application, nothing happens, and the "entry point" is not run (i am not getting any errors or anything) it just runs the default HTML welcome file and thats it. with out any GWT.
what am i doing wrong, i am surly misunderstanding something about how all this should work.
can anyone help me out please.
You need to select that you are running on an external server:
That is a question that can't just be answered with yes or no. It all depends on your overall architecture and what you are trying to achieve.
As I said, if it is both the same application I'd recommend to integrate the Spring project into the web project. (and if that's the case, the spring project does not need to be a web project)
If the spring project is its own application and maybe running on a different server, keep them separated. Extend the spring project so it offers the functionality (via ejb or webservice) the gwt-web project needs.
Nevertheless, I recommend you do some reading about how Java EE applications should be designed and what the different tiers (client, server/service, business, etc) are for. Oracle/Sun offers some good articles. For example: http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/ or http://docs.oracle.com/javaee/5/tutorial/doc/bnaay.html#bnabb.

Replacing GWT RPC with JBoss Errai

I myself haven't tried JBoss Errai at all, but I am thinking of migrating the server-side services of my current GWT project into a new project that will be now treated as a platform.
The services in the currect project that are accessed via RPC can be commonly used with other projects as "base platform."
So, I am thinking of using using JBoss Errai for this scenario. And so, the new "base" platform project will be non-GWT and that Ajax apps built with GWT will just call into this platform for authentication, storage, etc.
Is this a good approach anyway?
If your project actually runs fine, why would you want to change it? you can instead, integrate the errai framework and when you want to add a new component, you can take advantage of the features of errai ;-)

GWT integration in existing Java EE application

I am new to GWT. I have developed a GWT application in version-1.6.4 and it is working fine. Now I want to integrate with that project in existing Java EE application. I don't know how to go ahead.
Where to copy the GWT source code in this existing Java EE application? I am also using RPC in GWT.
Can anyone provide help on this?
GWT is just a set of javascript and HTML files, so the most basic form of integration is just to put them in a folder in the same place your as your web pages go.
One step up from there would be to integrate the gwt Compiler in with your build process. If you use Netbeans there is a good plugin called GWT4NB that will handle all of this process for you, so that when you build the WAR of your project it will build the GWT portions of it as well. There would probably be something similar for Eclipse. You could also do all this by hand using maven or ant.
You would tell the compiler where you want it to put the generated files, which again, would be in the same location you put your web pages for your WAR project. The RPC side of it will still work just fine no matter where you put the files.