简体   繁体   English

使用TomCat实例调试GWT服务器端代码

[英]Debugging GWT server side code using a TomCat instance

I'm setting up a project to use MySQL as the datasource and I'm running into a couple problems. 我正在建立一个使用MySQL作为数据源的项目,但遇到了一些问题。

  1. It appears the MySQL drivers for the Java side are incompatible with the built in GWT Jetty instance. 看来Java端的MySQL驱动程序与内置的GWT Jetty实例不兼容。 Really? 真?
  2. I can configure a TomCat instance and get MySQL Driver working, but I can't debug inline (Client & server together) like I normally would be able to do using the Jetty instance in dev mode, according to Google Docs . 我可以配置Tomcat实例并获得MySQL驱动程序的工作,但我不能调试内联(客户端和服务器一起)像我通常将能够使用开发模式码头实例做,根据谷歌文档

I spent quite a while deciding between a PHP or Java backend, and one of the main advantages besides the GWT RPC mechanism was the fact that GWT provides a nice Development environment if you use Java. 我花了相当长的时间在PHP或Java后端之间做出决定,除了GWT RPC机制之外,主要优势之一是,如果您使用Java,则GWT提供了一个不错的开发环境。

Has anyone encountered the need to use a data source other than appEngine? 有没有人遇到使用appEngine以外的数据源的需要? How did you setup dev environment? 您是如何设置开发环境的?

I do believe the MySQL JDBC driver is "compatible" with the embedded Jetty; 我相信MySQL JDBC驱动程序与嵌入式Jetty是“兼容的”。 but maybe you were in an AppEngine project, in which case the embedded Jetty server forbids the use of classes that are not compatible with AppEngine (so you have at dev time a behavior as similar as possible with the production environment on Google's servers). 但是也许您在一个AppEngine项目中,在这种情况下,嵌入式Jetty服务器禁止使用与AppEngine不兼容的类(因此在开发时,您的行为与Google服务器上的生产环境尽可能类似)。

To debug your server code running in Tomcat, you either need to launch it (the server code) using Eclipse WTP (or equivalent if you don't use Eclipse), or launch your Tomcat instance with the appropriate debug arguments eg -agentlib:jdwp=transport=dt_socket,address=8788,server=y,suspend=y , and then debug it as a "Remote Java Application" (in Eclipse, I don't now how they name it in other IDEs). 要调试在Tomcat中运行的服务器代码,您需要使用Eclipse WTP(如果不使用Eclipse,则等效)启动它(服务器代码),或者使用适当的调试参数启动Tomcat实例,例如-agentlib:jdwp=transport=dt_socket,address=8788,server=y,suspend=y ,然后将其调试为“远程Java应用程序”(在Eclipse中,我现在不知道它们在其他IDE中的命名方式)。 You can then launch your DevMode in -noserver mode (and in debug) to debug your server and client at the same time (yes, you'll actually have 2 debug sessions). 然后,您可以在-noserver模式下(和在调试中)启动DevMode以同时调试服务器和客户端(是的,实际上您将有2个调试会话)。

Note that the doc you refer to (whose latest version can be found here ) doesn't deal with debugging the server-side code, as it's highly dependent on the server you use, how and where it's deployed, etc. GWT code on the server side is just a standard servlet, so there's nothing specific to GWT re. 请注意,您所引用的文档(可在此处找到其最新版本)不会涉及调试服务器端代码,因为它高度依赖于您所使用的服务器,其部署方式和部署位置等。服务器端只是一个标准的servlet,因此GWT re没有什么特别的。 how to debug the server-side code. 如何调试服务器端代码。

FYI, we do use a standalone Jetty instance (not the embedded Jetty server) for more than a year using the above setup. 仅供参考,使用上述设置,我们会使用独立Jetty实例(而不是嵌入式Jetty服务器)超过一年。

You can use GWT and Tomcat and still be able to debug both client and server side. 您可以使用GWT和Tomcat,但仍然可以调试客户端和服务器端。 Look at the jetty startup parameters in Eclipse. 查看Eclipse中的码头启动参数。

I have been in a similar position few years ago and decided to use Jetty for development and tomcat for testing. 几年前,我担任过类似的职位,决定使用Jetty进行开发,并使用tomcat进行测试。

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

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