Debug with Eclipse

來源:互聯網
上載者:User

標籤:

 

In this post we are going to see how to develop applications using Eclipse and Portofino 4. The traditional development of a web application in Eclipse requires the creation of a web project and its deployment on an application server such as Tomcat. This is certainly possible even with Portofino, but it has two drawbacks: first redeployment is slow and second this life cycle loses the capability of Groovy scripts to be edited on live systems.

In this post we propose the idea to create a project that points to the web application running under Tomcat. Therefore we can harness the power of the IDE and to maintain the capability to make changes on the live system without redeploy.

Why use an IDE? Portofino can be managed only through a browser and, optionally, with a text editor. But the use of an IDE such as Eclipse, facilitates to create and edit xml pages, jsp and groovy scripts. With Eclipse we can debug Groovy scripts, browse and search classes, have syntax highlighting, auto-completion, import and automatic functions refactoring.

Note. During realization of this post I used the latest version of Eclipse Juno and the bundle "Eclipse IDE for Java EE Developers".

Project setupWithin Eclipse, create a new Dynamic Web Project  STEP1. Set the project name and use the war expanded under Tomcat (ROOT direcetory) as "Location". We can ignore the other parameters and click on "Next".   STEP 2. We can remove the "src" directory that Eclipse created, and add the directory "apps / default / groovy" where shared groovy scripts are located.   STEP 3. We set the Context root to "/", or the name of the context of your webapp,  and the Content directory to "/ apps / default",  Click on "Finish" and wait that  the process ends. To avoid dependency problems, we create a "User Library" with all the jars in WEB-INF/lib and the lib directory of Tomcat.To do this right click on the "Build Path> Configure build path ..." and create this library.  Now our project is ready to be managed by Eclipse.If you have never installed the appropriate Groovy plug-in, you still have problems editing scripts.GroovyTo install the Groovy plug-in Groovy refer to the website http://groovy.codehaus.org/Install+Groovy-Eclipse+PluginClick on "Help> Install New Software ..." , add the following URL and selecte packages as shown (url changes depending on the version of Eclipse).  Restart Eclipse and now our Groovy files have the syntax highlighting, and we can use the automatic import and autocompletion.  Remote Debug

Next step is to use Eclipse to debug our live application. To do this we need:

  1. configure Tomcat to start in debug mode
  2. configure Eclipse to connect to the remote server
For these steps you can refer to http://wiki.apache.org/tomcat/FAQ/Developing. To activate debug mode,  set two environment variables and starting Tomcat as shown below (the following code is for Linux or Mac)
export JPDA_ADDRESS=5005 export JPDA_TRANSPORT=dt_socket bin/catalina.sh jpda start
 In Eclipse click on "Run->Debug Configurations...".    Select a new "Remote Java Applications" and set the host and port, in our case is 5005,  the value of JPDA_ADDRESS variable.  And that‘s it. Put a break point in security.groovy, log in and you can use the Eclipse debug. Conclusions

In this post we configured Eclipse to develop live web applications in Portofino. Developing with an IDE has many advantages, first of all the possibility to debug your live application.

You can use other Java IDEs such as NetBeans or IntelliJ,  the configuration is similar to what done in this post.http://portofino.manydesigns.com/en/blog/eclipse-groovy-debug? http://www.jetbrains.com/idea/help/run-debug-configuration-cucumber-java.html http://www.jetbrains.com/idea/help/run-debug-configurations.html     

Debug with Eclipse

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.