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.
 
 
 
 
 
 
 

Debug with Eclipse的更多相关文章

  1. debug --- 使用Eclipse

    debug必知(快捷键若无效,有可能是与其它软件的快捷键发生冲突的原因) 1.F6  ——  单步执行代码,即顺序一行行地执行源码 2.F5  ——  跳入当前调用的函数的内部,即进入函数内部执行源码 ...

  2. Eclipse Debug 配置

    创建和使用 Debug 配置 Eclipse Debug 配置类似于运行配置但它是用于在调试模式下开启应用. 打开 Debug 配置对话框步骤为:Run > Debug Configuratio ...

  3. debug PostgreSQL 9.6.18 using Eclipse IDE on CentOS7

    目录 debug PostgreSQL 9.6.18 using Eclipse IDE on CentOS7 1.概览 2.建立用户 3.编译postgre 4.启动Eclipse 5.设置环境变量 ...

  4. Eclipse启动参数

    from 网络 eclipse 启动参数 -clean2013-- : eclipse 启动参数介绍(如添加插件时,如果不显示,则使用eclipse -clean启动) 其实,Eclipse是一个可以 ...

  5. [No000077]打造自己的Eclipse

    下载官网的Eclipse IDE for Java EE Developers 在根目录下的eclipse.ini文件中添加"-Dfile.encoding=UTF-8", 作用: ...

  6. Eclipse 语法提示

    新建一个txt 拷贝下面的文本,然后保存修改扩展名为.epf #Sat Nov :: CST /instance/org.eclipse.jdt.core/org.eclipse.jdt.core.c ...

  7. atitit.eclipse 新特性总结3.1--4.3

    atitit.eclipse 新特性总结3.1--4.3 Eclipse 3.1 1 Eclipse 3.2 Java开发工具的新特性 2 1. 内容辅助(Ctrl+Space)模板 2 2. 动态地 ...

  8. Eclipse远程调试(远程服务器端监听)

    前提:远程服务器上运行的WEB项目class对应的源码与本地项目中必须保持一致,也就是远程tomcat部署的项目就是本机项目打包过去的,而本机项目没有发生变动. 远程服务器端 服务器端配置eclips ...

  9. Eclipse Pydev 技巧汇编

    之前一直使用eclipse中默认的console.但是这个console并不是interactive的,如果数据比较小的时候还行,数据量一旦很大,则每次调试都需要重新再跑一遍程序,从而浪费很多时间. ...

随机推荐

  1. Swift - 使用UIView给页面添加4×4方格

    1,下面是一个利用UIView来给页面上绘制灰色方块的例子,效果图如下:    代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ...

  2. KMP(Knuth-Morris-Pratt)算法

    一.朴素匹配算法 也就是暴力匹配算法.设匹配字符串的长度为n,模式串的长度为m,在最坏情况下,朴字符串匹配算法执行时间为O((n - m + 1)m). 假设m = n / 2, 那么该算法的复杂度就 ...

  3. (2)入门指南——(7)添加jquery代码(Adding our jQuery code)

    Our custom code will go in the second, currently empty, JavaScript file which we included from the H ...

  4. codeforces584B Kolya and Tanya

    题目链接:http://codeforces.com/problemset/problem/584/B 解题思路:当n=1时,_______    _______   ______  三个数每位上可以 ...

  5. dtach-linux-分离功能-小工具 - 点点滴滴 Linux | 点点滴滴 Linux

    dtach-linux-分离功能-小工具 - 点点滴滴 Linux | 点点滴滴 Linux dtach-linux-分离功能-小工具 2013年05月20日 ⁄ Linux工具 ⁄ 共 1775字 ...

  6. latex命令替换之\newcommand

    有时候我们在用latex写文档的时候不想写很长的命令,那么我们自己定义一个新的命令来替换一段代码. 举例如下: \usepackage{booktabs} \usepackage{multirow} ...

  7. android之JSON 进行网络数据交换

    什么是JSON JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,易于阅读和编写,同一时候也易于机器解析和生成,很适合于server与client的交互. J ...

  8. Linux实现字符设备驱动的基础步骤

    Linux应用层想要操作kernel层的API,比方想操作相关GPIO或寄存器,能够通过写一个字符设备驱动来实现. 1.先在rootfs中的 /dev/ 下生成一个字符设备.注意主设备号 和 从设备号 ...

  9. 浅谈 PHP 神盾的解密过程

    原文:浅谈 PHP 神盾的解密过程 前些日子一个朋友丢了个shell给我,让我帮忙解密,打开源码看了下写着是 “神盾加密” , 牛逼闪闪的样子.百度下发现神盾是个很古老的东西,最后一次更新是在 201 ...

  10. PHP监測memcache服务端的执行状况

    . 代码例如以下,代码为memcache官方代码,引用在此.做一下简单的说明: 1.设置username和password define('ADMIN_USERNAME','admin'); // A ...