Debug with Eclipse

简介: 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 Ecl...

 

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 setup

Within 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.

Groovy

To install the Groovy plug-in Groovy refer to the website http://groovy.codehaus.org/Install+Groovy-Eclipse+Plugin
Click 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.
 
 
 
 
 
 
 
相关文章
|
缓存 安全 数据可视化
Java如何Debug - Eclipse
Java如何Debug - Eclipse
181 0
|
Android开发
Eclipse无法DEBUG
Eclipse无法DEBUG
173 0
|
程序员 Android开发
eclipse中debug不显示变量
当eclipse中debug不显示变量时应该如何做?本文带大家解决这个问题。
666 0
eclipse中debug不显示变量
|
Java Android开发
Eclipse Debug
Eclipse Debug
153 0
|
IDE Java 开发工具
Eclipse使用过程中快捷键的那些故事| Java Debug 笔记
Eclipse使用过程中快捷键的那些故事| Java Debug 笔记
112 0
|
XML Java 应用服务中间件
启动tomcat时,eclipse莫名奇妙自动跳转到debug模式
启动tomcat时,eclipse莫名奇妙自动跳转到debug模式
206 0
|
开发工具 Android开发 开发者
Eclipse 开发工具(debug 调试)|学习笔记
快速学习 Eclipse 开发工具(debug 调试)
118 0
|
Android开发 Java 开发工具
如何在eclipse中快速debug到想要的参数条件场景下
前言 俗话说,工欲善其事必先利其器。 对于我们经常使用的开发工具多一些了解,这也是对我们自己工作效率的一种提升。 场景 作为开发,我们经常会遇到各种bug,大部分的bug很明确,我们直接可以打断点定位到。
1354 0
|
Android开发 数据安全/隐私保护 iOS开发
mac版 eclipse 只能run不能debug的解决方案
mac:macOS Sierra 10.12.2 eclipse:Version: Neon.1a Release (4.6.1) debug时进度一直停在93%,然后超时报错: ERROR: transport error 202: getho...
1186 0
|
Java
怎样在myEclipse中使用debug调试程序?
怎样在myEclipse中使用debug调试程序?     最基本的操作是:     1.首先在一个java文件中设断点,然后debug as-->open debug Dialog,然后在对话框中选类后--> Run     当程序走到断点处就会转到debug视图下。
1066 0