使用 Eclipse 在 tomcat 上调试 GWT [英] debug GWT on tomcat using eclipse

查看:36
本文介绍了使用 Eclipse 在 tomcat 上调试 GWT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 GWT 2.4 并且已经编写了大量代码.我知道 GWT 插件附带的 Jetty 服务器对可以在项目中使用的 jar 进行非常严格的控制,以尽可能接近地模仿应用程序引擎.我需要部署到 tomcat 7.我在 eclipse 中修改了我的项目,并将其祝福"为动态 Web 项目,以便我可以导出...WAR 并将其上传到我的 QA 和生产 tomcat.

我需要帮助让应用程序在嵌入式 tomcat 上运行(和调试)(就像一个诚实的动态 Web 项目那样).我已经在 eclipse 中设置了 tomcat,并且我已经部署了我的 CAS 服务器 Web 应用程序.

我已经在这里和其他地方准备了大量旧的或令人困惑的帖子.基本上,我正在寻找与打包的 Jetty 服务器相同的调试环境,但是在我自己的 tomcat 上配置了 eclipse 中的 WTP ......所以我可以模仿我的生产环境(就像 Jetty 模仿应用程序引擎一样)

感谢任何帮助.

解决方案

它可能应该更容易一些,但它是可能的.这是我的做法:

1.设置网络服务器

  • 使用JavaEE 版本的Eclipse,我设置了Tomcat 7.0 服务器适配器,并在Preferences > 中定义了一个环境.服务器 >运行时环境
  • 文件>新 >项目... >网页/动态网页项目
    • 选择我在第一步中设置的目标运行时
    • 重要提示:在 Context Root 中,输入 /
  • 我创建了一个 HTML 文件和一个 Servlet,然后尝试使用 Debug As > 运行设置.在服务器上调试

2.添加 GWT 代码服务器

  • 项目>属性 >谷歌 >网络工具包使用 Google 网络工具包
  • 重要提示:我总是需要更改 Java Build Path 中的顺序(Project > Properties > Java Build Path > Order and Export),请参阅 http://code.google.com/p/google-web-toolkit/issues/detail?id=4479 - gwt-dev.jar 必须在路径之上.
  • 项目>属性 >谷歌 >Web 应用程序:War directory = "WebContent",同时勾选"Launch and deploy from this directory"
  • 我创建了一些示例 GWT 内容(我创建了一个示例 GWT 项目,并复制了大部分内容)
  • 我尝试使用 GWT 编译项目.这告诉我,如果我的构建路径顺序正确 - 否则,编译器会提前失败并显示java.lang.NoSuchFieldError:warningThreshold".
  • Debug As >Web 应用程序 - 只是为了创建调试配置.停止调试.编辑调试配置(Run > Debug Configurations...),取消选择运行内置服务器".再次开始调试.

现在,我终于可以同时调试服务器和客户端部分(我仍然需要单击两个调试图标来启动这两个部分!)我可以从开发模式"视图管理客户端,而从服务器"视图.归根结底,它工作得很好,并且使用资源更改时自动发布"功能(Servers view > myServerName > Open > Publishing),有时甚至比集成更好码头.

I'm using GWT 2.4 and have a ton of code already written. I understand the Jetty server that comes with the GWT plugin has very tight control over the jars that can be used in a project to mimic app engine as closely as possible. I need to deploy to tomcat 7. I modified my project in eclipse and "blessed" it as a dynamic web project so I can export...WAR and upload it to my QA and production tomcat.

I need help with getting the app to run (and debug) on an embedded tomcat (like an honest dynamic web project would). I already have tomcat setup in eclipse and I have my CAS server web app deployed to it.

I've ready tons of either old or confusing posts here and elsewhere. Basically, I'm looking for the same debugging environment I would get with the packaged Jetty server, but on my own tomcat configured with WTP in eclipse...so I can mimic my production environment (just like Jetty mimics app engine)

any help is appreciated.

解决方案

It should probably a little bit easier, but it's possible. Here's how I do it:

1. Setting up the web server

  • Using the JavaEE edition of Eclipse, I set up the Tomcat 7.0 server adapter, and define an environment in Preferences > Server > Runtime Environments
  • File > New > Project... > Web/Dynamic Web Project
    • Select the target runtime I set up in the first step
    • Important: In Context Root, enter /
  • I create an HTML file and a Servlet, and then try running the setup using Debug As > Debug On Server

2. Adding the GWT code server

  • Project > Properties > Google > Web Toolkit > Use Google Web Toolkit
  • Important: I always need to change the order in the Java Build Path (Project > Properties > Java Build Path > Order and Export), see http://code.google.com/p/google-web-toolkit/issues/detail?id=4479 - gwt-dev.jar must be pretty much on top of the path.
  • Project > Properties > Google > Web Application: War directory = "WebContent", also check "Launch and deploy from this directory"
  • I create some sample GWT content (I create a sample GWT project, and copy most of it over)
  • I try to GWT compile the project. This shows me, if I got the build path order right - otherwise, the compiler fails early with "java.lang.NoSuchFieldError: warningThreshold".
  • Debug As > Web Application - just to create a debug configuration. Stop the debug. Edit the debug configuration (Run > Debug Configurations...), deselect "Run built-in server". Start the debug again.

Now, finally, I can debug both the server and the client part (I still need to click two Debug icons to start both!) I can manage the client side from the "Development Mode" view, and the server side from the "Servers" view. At the end of the day, it works great, and using the "Automatically publish when resources change" feature (Servers view > myServerName > Open > Publishing), sometimes even better than with the integrated Jetty.

这篇关于使用 Eclipse 在 tomcat 上调试 GWT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆