how to check gwt application in dev mode from another computer - gwt

I am developing a GWT application on my Mac and now I'm supposed to test it in IE on my PC.
However, I don't want to copy the codes to PC in order to rebuild the project and finally to test it.
Nor do I want to setup the whole Apache + Tomcat server on my Mac to deploy the project so that my PC can access that web application.
Is there any way I can run my GWT application in debug mode on my Mac, and just test it out in IE on my PC? I'm using Spring + Maven + Eclipse + GWT.

In your run configuration of eclipse use -bindAddress 0.0.0.0 and this allow jetty to receive traffic from outside localhost.
In the Eclipse menu
Run > Debug Configurations...
Confirm your project is selected left under Web Applications > Project Name
Select the Arguments Tab on the right panel
Under "Program Arguments:" append the argument "-bindAddress 0.0.0.0"
From there you can debug from a remote machine in Development Mode

set -bindAddress 0.0.0.0 in (x)=Arguments tab in "Run Configuration" as stated above. when you run your application GWT will use your computer IP in launch URL. after opening the URL in your browser, click on GWT toolbox on the right of Chrome address bar which will open "GWT Developer Plugin Options". now just add your IP to the list of webserver exceptions.

See Debug GWT application in a remote browser.

for maven, you can run as
mvn gwt:run -Dgwt.bindAddress=0.0.0.0

Related

Debug Tomcat Web Application in Eclipse

I have a Advanced Java Application(Spring+Hibernate) with Maven. Project runs without any error.
I follow below process to test the application.
Build War using below command.
C:\Dev\ProjectApp> mvn clean package -Dmaven.test.skip=true
This builds war file inside target folder(C:\Dev\ProjectApp\target).
Place Application.war inside webapps folder(C:\Apps\Apache\Jakarta\Tomcat6\webapps)
run startup.bat from Tomcat6\bin folder.
hit the application in web Browser (http://localhost:8080/).
I want to debug this application from eclipse IDE itself. While application runs in webbrowser. I want to debug using breakpoints.
What are the steps to run this application in eclipse? What are constraints involved in this?
Thanks in Advance !
To simply debug the flow of the application, you can use the eclipse as the basis.
Goto the server view and create a new tomcat server (or any server that you use for dev). Next right-click on your project --> run as --> run on server and select the server that you just created. Keep in mind that the server should have all the configurations that you need to have to run the application. If your project requires some custom settings in the application server, then tell eclipse to take control of the server installation by selecting "Use Tomcat installation". (double click on the server to configure it)
Next add debuggers and start the server from within eclipse.
Happy debugging !
Set the environment variables first
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
You can edit the startup.bat to have
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
and start in the same way as above.
After this you can have your eclipse open a remote debugging session that connects to localhost:8000.
However, I would strongly recommend to use the WTP plugin in eclipse to build and start/stop the tomcat from within eclipse itself.

Running GWT on tomcat in eclipse

I am trying to get a GWT Project running on a Tomcat 7 server in eclipse. I installed Tomcat and i can run other web application out of eclipse on Tomcat without a problem.
Now i generated a gwt maven project for eclipse with the following command and importet it as maven project to eclipse:
"mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin"
I can run this now as Web application (with the google plugin) and i can build a "war" with maven and deploy this with the Tomcat management console on the server. Both is working. But if i choose the option in eclipse "Run on server" and choose tomcat than just the html is loaded but not the application itself. See the screenshot: It doesn't find the "GWTModule.nocache.js".
This file is available in the target folder. What do i have to change to tell tomcat to look in the correct directory?
Tomcat is not able to run GWT code in development mode. You can use Tomcat for server side code, but in this case you need to run GWT development mode with -noserver option (to prevent built-in Jetty instance from running). See this article for more details.
I would recommend using the wtp plugin for eclipse. If you do this you can add your project/resource to tomcat when adding a new server. Here are the steps to use if you already have your project imported into eclipse.
Window -> Show View -> Servers
In Servers
New -> Server -> Choose apache tomcat
Point to the location of your tomcat installation/download
Next
At this point you should be able to add your gwt-maven project which will add the target/project.war to the tomcat modules.
Save it
Click on the newly added server, then click the modules tab at the bottom kind of hard to see.
This should have your project shown in the list of web modules.
Start your tomcat instance then on your gwt application right click and choose Run As -> Web application. Make sure your configuration settings are correct and when the development server starts it should give you the development url to browse to.
You can configure some aspects of tomcat in the overview tab, I would recommend making sure that "Modules auto reload by default" is checked so that tomcat will watch the filesystem for class changes.

How to configure gwt application on tomcat for debugging?

I am trying to debug a GWT application on Tomcat, but I don't know how to run/debug my application on Tomcat in Eclipse. I have so many links but I can't get a proper result.
I'm using -noserver -port 8080 and war file configuration but every time I get an error 404 while I run the application.
Here are some links that I follow but I can't configure:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/7511aca28b5f683c
https://developers.google.com/eclipse/docs/faq#gwt_in_eclipse_for_java_ee
http://jxpang.blogspot.in/2010/11/configure-external-tomcat-7-server-in.html
update
I am having same url but i think i am doing wrong configuration. is any body has proper solution for configure gwt web application with apche tomcat with debugging.
I want step by step configuration and running tutorial
please help me.
So you connect to the local server, but it can't resolve your URL?
If you stick with all the defaults, then in dev-mode you would use the following URL:
http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997
But when configured on an external server you would need:
http://localhost:8080/MyApplication/index.html?gwt.codesvr=127.0.0.1:9997
Also make sure that in the 'Server' tab of your Debug configuration the option Run built in server is unchecked.
Hope this helps!
In Eclipse: right-click on your GWT project, and choose "Run As web Application (running on an external server)"
Then you can fill the field External root server (dns/ip and webapps folder for tomcat)

How to debug a GWT application running on OSGi?

I'm developing a web UI using GWT. While working only with the widgets I could debug from Eclipse using the Firefox extension, but now that I'm integrating the UI with other OSGi bundles I cannot use this solution.
For deploying the GWT application I create the .war and convert it to an OSGi bundle using BND. Then I launch the OSGi container with all the bundles using Pax Runner and Pax Web and the application works correctly, but when something fails in the generated javascript code I don't have any decent output error or debugging facility.
Is there any way to launch the GWT application in "debug mode" from OSGi?
Any other idea that could help in this scenario?
Update: Could it be possible to instantiate com.google.gwt.dev.DevMode or its part with the browser connector from the Activator?
I've finally managed to launch development mode using OSGi, GWT and optionally eclipse. The solution was on the -noserver flag of the GWT dev mode, it's not aware of the changes in code while the application is running, but it can be used for debugging the compiled code and to receive the exception traces.
I also managed to run the development shell without eclipse, but if you are not interested on this solution you can directly jump to the eclipse integration section.
Without Eclipse (only exceptions, no debug)
You need to know the following information:
Where do you have your source ($SRC)
Where do you have your GWT libraries ($GWT_PATH), specially gwt-user.jar and gwt-dev.jar.
(Optionally) the port from wich your HTTP OSGi server serves the application ($PORT).
The startUp url of your application ($URL)
The package containing the .gwt.xml file for your application ($PACKAGE).
Then you need to run:
java -cp $SRC:$GWT_PATH/gwt-user.jar:$GWT_PATH/gwt-dev.jar \
com.google.gwt.dev.DevMode -noserver -port $PORT \
-startupUrl $URL $PACKAGE
E.g.:
java -cp src/:lib/gwt-2.0.3/gwt-user.jar:lib/gwt-2.0.3/gwt-dev.jar \
com.google.gwt.dev.DevMode -noserver -port 8080 \
-startupUrl httplocalgui.html es.warp.samples.httplocalgui
And finally you only need to deploy your application as usual, in my example I do it with pax-runner and pax-web, using the default port 8080.
With Eclipse
Open the debug configuration for your project
Go to Server tab and uncheck "Run built-in server"
Go to Attributes tab and add "-port 8080" (if 8080 is the port used by your web container). I think that this argument without the built-in server is only used to create the url that the development mode generates to invoke the browser (or that elipse uses to generate an url you can copy and paste in your browser's address bar).
Deploy your application.
Access it from a browser with the GWT extension installed (and don't forget to add ?gwt.codesvr=127.0.0.1:9997)
I had the same problem lately and unfortunately I haven't found any good solution.
Eventually I created mock implementations of all GWT services I am using in my client side code. When I need to debug client side code I am just switching to these services instead of real services using OSGi underneath. Then in Eclipse I can run GWT application in debug mode. This is far from perfect and requires some work with mocks but it works for me (at least now).

Can I debug an application which is running on other eclipse instance?

I have two eclipse instances running.
And in one I have the code base.
And in other eclipse i am running the application.
So can I debug this application in the eclipse where I have code base?
I imagine your build produces a JAR file? if so, then you can run the JAR from the console and then plug the eclipse debugger.
Check this tutorial, that is clear and with screenshots
You should be able to launch a remote debug session
1/ Specify the following option when launching the app from the first eclipse
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
2/ Launch a Remote Java App (Run > Debug> Debug Configurations... > Remote Java Application.)
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
(if port 8000 is free) in order to debug the app from the "code base" eclipse.
See Remote Debugging with Eclipse.
You can specify the sources in the Remote Java App configuration by referencing your own code base.
Yes, you can attach the debugger to a remote JVM. See How to attach debugger to running process?