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. Cmpletepack coming~^.^

    昨天小小总结了01背包:01背包 不足之处还望多提意见~噶呜~ 今天来总结一下完全背包: 完全背包:    基本思路:类似于01背包,所不同的是每种物品有无限件.也就是从每种物品的角度考虑,策略已经不 ...

  2. html浏览器兼容性的 JavaScript语法

    1.      在FireFox中能够使用与HTML节点对象ID属性值同样的JS变量名称.可是IE中不行. 解决的方法:在命名上区分HTML节点对象ID属性值和JS变量 2.      IE不支持JS ...

  3. SilkTest高级进阶系列6-motif tag

    看SilkTest代码的时候不小心看到winclass.inc里面的一些类申明使用的是motif tag,例如: [-] winclass MessageBoxClass : DialogBox [ ...

  4. POJ2599+POJ2082【最大矩形面积】

    题目链接:http://poj.org/problem?id=2559 题目链接:http://poj.org/problem?id=2082 这一类题目的解法,不知自己闲着没事就做了两个. 果然压栈 ...

  5. 怎样用js得到当前页面的url信息方法(JS获取当前网址信息)

    设置或获取对象指定的文件名称或路径.window.location.pathname 设置或获取整个 URL 为字符串.window.location.href; 设置或获取与 URL 关联的端口号码 ...

  6. Hbase经常使用命令

    hbase shell命令的使用 再使用hbase 命令之前先检查一下hbase是否执行正常 hadoop@Master:/usr/hbase/bin$ jps 2640 HMaster 27170 ...

  7. Linux源文件夹结构呈现

    1.arch文件夹: - 相关的存储在不同平台上的代码,每个平台都采用了不同的文件夹来区分. ******Alpha平台 ******Arm平台 ******Arv32平台 ******X86平台 2 ...

  8. IOS获取来电去电来电归属系统通知达到效果(一)

    这里的原理是获得到呼叫系统通知,然后根据本地呼叫电话号码,相应的电话联系. 一世.   来电显示是不是在地址簿中的联系人, 这是当第一个加入一个临时的联系人在您的电话簿(它是创建一个新的接触,并保存相 ...

  9. 【C++】动态开辟二维数组

    二维数组在内存中的分配例如以下: C方式呈现: <span style="font-size:18px;"> #include <iostream> usi ...

  10. 深入了解java同步、锁紧机构

    该薄膜还具有从本文试图一个高度来认识我们共同的同步(synchronized)和锁(lock)机制. 我们假定读者想了解更多的并发知识推荐一本书<java并发编程实战>,这是一个经典的书, ...