简体   繁体   English

调试和运行GWT / GAE应用程序的客户端/服务器代码

[英]Debugging and Running Client/Server Code for GWT/GAE App

I'm developing a GWT app that will be deployed to GAE. 我正在开发一个将部署到GAE的GWT应用程序。 I have installed the Google-Eclipse plugin which also pulled down the GWT and GAE SDKs. 我已经安装了Google-Eclipse插件,它也下载了GWT和GAE SDK。 But now that I am sitting down and actually thinking about things, I've become very confused as to how to both debug and run apps locally on my machine. 但是现在我正坐下来实际思考问题,我对如何在我的机器上本地调试和运行应用程序感到非常困惑。

Normally, when I have a Java web app (I deploy to Tomcat; I'm just familiar with it), my options are as follows: 通常,当我有一个Java Web应用程序(我部署到Tomcat;我只是熟悉它)时,我的选项如下:

  • Create a remote Debug Configuration for my app, deploy the WAR to my local Tomcat container, but in such a way that I can debug it (set breakpoints, step through server-side code) right from inside Eclipse 为我的应用程序创建一个远程调试配置,将WAR部署到我的本地Tomcat容器,但是我可以从Eclipse内部调试它(设置断点,逐步执行服务器端代码)
  • Just deploy it to the Tomcat container, fire up a browser at http://localhost:8080/MyApp and start using/manually-testing the app locally 只需将其部署到Tomcat容器,在http://localhost:8080/MyApp启动浏览器并开始在本地使用/手动测试应用程序

I want to accomplish the same, but with GWT and GAE there are so many options for both, and they become exponentially more confusing (to a newcomer such as myself) when you pair them together on the same machine: 我想要完成相同的工作,但是对于GWT和GAE,两者都有很多选择,当你在同一台机器上将它们配对时,它们会变得更加令人困惑(对于像我这样的新手):

Ultimately, I'd like to be able to do the following: 最后,我希望能够做到以下几点:

  • Debug the server app, including setting breakpoints, stepping through code, etc., right from inside Eclipse 从Eclipse内部调试服务器应用程序,包括设置断点,单步执行代码等
  • Debug the client app, including setting breakpoints, stepping through code, etc., from inside a browser plugin like Firebug or Chrome Developer Tools, locally on my machine 在我的机器本地调试客户端应用程序,包括设置断点,逐步执行代码等,从Firebug或Chrome开发者工具等浏览器插件中调试
  • Debug the app (both client- and server-side code in tandem), including setting breakpoints, stepping through code, etc., right from inside Eclipse 从Eclipse内部调试应用程序(串联客户端和服务器端代码),包括设置断点,单步执行代码等
  • Same as above (debug the entire app, client- and server-side), from inside Eclipse, but where the server is running on a different (remote) machine. 与上面相同(调试整个应用程序,客户端和服务器端),从Eclipse内部开始,但服务器在不同的(远程)计算机上运行。 This way I can debug my app as it is running on my QA machine/environment, right from inside the Eclipse instance on my development machine 这样我可以调试我的应用程序,因为它在我的QA机器/环境上运行,就在我的开发机器上的Eclipse实例内部
  • Run the app locally and simulate production; 在本地运行应用程序并模拟生产; that is, deploy the backend to my GAE app dev server, and then open up a browser and go to the correct URL for accessing my app as it is served up by the local GAE dev appserver 也就是说,将后端部署到我的GAE app dev服务器,然后打开浏览器并转到正确的URL以访问我的应用程序,因为它由本地GAE dev appserver提供

I think the root of my confusion stems from the fact that both GWT and GAE SDKs run in so-called "dev modes", and because they address different tiers (client and server) its tough to wrap my head around what setup/configs are necessary to be able to isolate them if needed, or test them in tandem if needed. 我认为我的困惑的根源在于GWT和GAE SDK都在所谓的“开发模式”中运行,并且因为它们针对不同的层(客户端和服务器),所以很难围绕什么设置/配置必要时能够隔离它们,或者在需要时串联测试它们。 Thanks in advance for any help here! 在此先感谢您的帮助!

I'll try to answer your questions as best I can. 我会尽力回答你的问题。 I recently inherited a code base of GWT, and have used app engine, so I'll do my best. 我最近继承了GWT的代码库,并使用了app引擎,所以我会尽我所能。

First of all, your sever side code is run by GWT SDK in a Jetty Servlet container. 首先,您的服务器端代码由Jetty Servlet容器中的GWT SDK运行。 Your client side code is compiled to javascript, and run in the browser. 您的客户端代码编译为javascript,并在浏览器中运行。 Therefore, you can run your client code against any servlet server backend really easily. 因此,您可以非常轻松地针对任何servlet服务器后端运行客户端代码。 So when you are running GAE in 'dev mode' you have compiled your java, and are running a servlet with a GWT entrypoint in the GAE dev servlet container. 因此,当您在'dev模式'中运行GAE时,您已编译了Java,并且正在GAE dev servlet容器中运行带有GWT入口点的servlet。

Setting up a local environment is fairly easy. 设置本地环境相当容易。 When in eclipse, you can right click on your project and do 'Run As' or 'Debug As'. 在eclipse中,您可以右键单击您的项目并执行“Run As”或“Debug As”。 In the 'Run Configurations' and 'Debug Configurations' option, you will see a Google icon in the list titled 'Web Application'. 在“运行配置”和“调试配置”选项中,您将在标题为“Web应用程序”的列表中看到Google图标。 You should create a profile to remember the options. 您应该创建一个配置文件来记住选项。

This configuration gives you a few options. 此配置为您提供了一些选项。 If you have the appropriate GAE files, you can go to the 'App Engine' tab and configure options for that there. 如果您有相应的GAE文件,则可以转到“App Engine”选项卡并为其配置选项。 Under the 'Sever' tab, you have two options. 在“服务器”标签下,您有两种选择。 If you check the 'run built-in server' option. 如果选中“运行内置服务器”选项。 GWT will run your servlets in it's Jetty container, and run the GWT client code server. GWT将在其Jetty容器中运行您的servlet,并运行GWT客户端代码服务器。 If not, it will only run the client code server which allows you to change client code on the fly, and debug client code in eclipse. 如果没有,它将只运行客户端代码服务器,允许您动态更改客户端代码,并在eclipse中调试客户端代码。 Eclipse will give you a nifty URL such as the following. Eclipse将为您提供一个漂亮的URL,如下所示。

http://127.0.0.1:8888/index.jsp?gwt.codesvr=127.0.0.1:9997

This is really two parts, and weather you are using the built in jetty servlet container or not, it will look the same. 这实际上是两部分,天气你使用内置的码头servlet容器,它看起来是一样的。

The first part is the http://127.0.0.1:8888/index.jsp -This is your running servlet container, it can be running on tomcat, web-logic, or GWT dev server, or any servlet container. 第一部分是http://127.0.0.1:8888/index.jsp这是你正在运行的servlet容器,它可以在tomcat,web-logic或GWT dev服务器或任何servlet容器上运行。

The second part is the ?gwt.codesvr=127.0.0.1:9997 -This is some GWT magic that when used in conjunction with the browser GWT development plugin, will allow you to change client code at runtime, and debug your javascript as java in eclipse. 第二部分是?gwt.codesvr=127.0.0.1:9997这是一些GWT魔术,当它与浏览器GWT开发插件结合使用时,将允许你在运行时更改客户端代码,并调试你的javascript为java in日食。

If I'm only doing client side code changes, I will sometimes replace the http://127.0.0.1:8888/index.jsp with our dev server url : http://mydevserver:1234/myapp/index.jsp?gwt.codesvr=127.0.0.1:9997 This allows me to run the client code server locally without running the server side code locally. 如果我只进行客户端代码更改,我有时会用我们的开发服务器url替换http://127.0.0.1:8888/index.jsp http://mydevserver:1234/myapp/index.jsp?gwt.codesvr=127.0.0.1:9997这允许我在本地运行客户端代码服务器,而无需在本地运行服务器端代码。 Note that I can access the client code that was deployed to dev by accessing the dev servlet directly without the gwt.codesvr parameter. 请注意,我可以通过直接访问dev servlet而不使用gwt.codesvr参数来访问部署到dev的客户端代码。

I hope this helps. 我希望这有帮助。 I may be able to elaborate on parts of this if you have questions. 如果您有疑问,我可以详细说明其中的部分内容。

This Google Eclipse Plugin should get you running. 这个谷歌Eclipse插件应该让你运行。 It is basically a plugin for Eclipse that will help you create GWT + GAE application (with few clicks and type) then be able to run your app directly from Eclipse. 它基本上是Eclipse的一个插件,可以帮助您创建GWT + GAE应用程序(只需点击几下和类型),然后就可以直接从Eclipse运行您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM