debug GWT on tomcat using eclipse

后端 未结 2 960
误落风尘
误落风尘 2020-12-06 07:26

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 use

2条回答
  •  一生所求
    2020-12-06 08:27

    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.

提交回复
热议问题