How to configure gwt application on tomcat for debugging? - eclipse

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)

Related

Running tomcat by adding external server vs inbuilt maven

I want to know the difference in running an application in eclipse by both ways below:
1)Run the application as maven build with 'tomcat' dependency in the pom.xml
2)download tomcat from apache site and add the server, run the tomcat and then run the application as server.
Lets say, my project name is 'messenger'. When I did using first step, i can access with below link"
http://localhost:8080/
but when i did as second step, i can access using below link:
http://localhost:8080/messenger/
can someone, please explain why the difference? arent both the same?

Eclipse dynamic web project not running on tomcat server

I've installed a Tomcat server to my Eclipse (Kepler), so why does it need an internet connection when I run a dynamic web project?
If I understood your question correctly - you need to start your tomcat server before you access your application. It's not related to internet connection.
Overall Steps:
1.Follow THIS post answer steps to setup tomcat into eclipse
2.Add your application artifact (.war or .jar file) into tomcat server by right click on server -> Add and Remove...
3.Select your artifact and click on add button. You will see artifact moved from Available to Configured box.
4.Clean entire project (Project -> Clean)
5.Start you server and check console for any error.
6.If you don't see any error - access your application
Hope this helps!!

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.

Tomcat and Eclipse server configuration

I installed tomcat on my ubuntu. When i create a new Dynamic Web Project I choose the tomcat 7 server. When I launch my page it works on localhost:8080/app/page but if I go on localhost:8080 it give me a 404 error.
If i start tomcat server with an external script like /etc/init.d/tomcat start, it works but I cannot launch my app because it says that the port 8080 is already occupied (by the other instance of tomcat).
I'm confused on how set everything, I would start tomcat at boot and link that instance for my apps.
Can you explain how I hato to do?
Open the server configuration in the Servers tab on Eclipse. On "Server Locations", mark "Use Tomcat installation".
EDIT: to be more precise, this will make Eclipse "take control" of your Tomcat folder. So it will not just make a replica on eclipse .metadata and deploy only your apps on it; instead it will be like if you ran bin/startup, but using some of the configuration defined on Servers view. So if you go localhost:8080 you will see the Welcome page, because /ROOT is now started by Eclipse.
So, I am not against "Starting/Stopping" the server from eclipse but to keep it simple, I think you can stop the server from eclipse (Click on windows/showview/Servers and then stop the server). Then I think you should not get an error if you start tomcat again from external script. Then you can right click on your dynamic web project in eclipse and export it as a war file inside tomcat-install--dir/webapps. Where your web application is available (on which context) depends on the web.xml file. If you need further info on this plz let me know.

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).