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)
  1. 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. android打包apk时混淆遇到的问题

    android打包apk的时候一般会选择混淆,而在eclipse中常使用的是proguard来混淆.有很多时候引用了第三方包的时候会导致打包不成功,或者打包成功不能运行的情况. 首先看看正常的prog ...

  2. android使用篇(四) 注解依赖注入IOC实现绑定控件

    在android使用篇(三) MVC模式中提到一个问题: 1) 视图层(View):一般採用XML文件进行界面的描写叙述,使用的时候能够很方便的引入,可是用xml编写了,又须要在Acitvity声明而 ...

  3. Github干货系列:C++资源集合-

    Awesome CPP,这又是一个 Awesome XXX 系列的资源整理,由 fffaraz 发起和维护.内容包括:标准库.Web应用框架.人工智能.数据库.图片处理.机器学习.日志.代码分析等. ...

  4. 对称加密算法DES,3重DES,TDEA,Blowfish,RC5,IDEA,AES。

    对称加密算法:DES,3重DES,TDEA,Blowfish,RC5,IDEA,AES. 1.对称加密算法 1.1 定义 对称加密算法是应用较早的加密算法,技术成熟.在对称加密算法中,数据发信方将明文 ...

  5. A Game of Thrones(18) - Catelyn

    “We will make King’s Landing within the hour.” Catelyn turned away from the rail and forced herself ...

  6. Tkinter隐藏窗口再让他显示出来的例子

    隐藏主要是 : withdraw()函数. 重新显示出来主要是: update()和deiconify()函数. 来源:http://www.blog.pythonlibrary.org/2012/0 ...

  7. ArrayList线程不安全?

    ArrayList是线程不安全的,轻量级的.如何使ArrayList线程安全? 1.继承Arraylist,然后重写或按需求编写自己的方法,这些方法要写成synchronized,在这些synchro ...

  8. [Sqlite] 移动嵌入式数据库Sqlite日报SQL操作语句汇总

    ,EXPLAIN分析 没有建立索引之前.分析都是表扫描: sqlite> EXPLAIN SELECT *  FROM COMPANY  WHERE Salary < 20000; add ...

  9. poj3126解题报告

    题意:简单的说就是:有一个人门牌号是一个四位数的整数,并且还是一个素数,现在他想要换成另外一个四位数且是素数的门牌号,而且,每次都只能更换这个四位数的一个位置的数 ,也就是每换一次都只改变一个数字,而 ...

  10. VMware3种网络模式

     VMware网络配置详解一:三种网络模式简介 安装好虚拟机以后,在网络连接里面可以看到多了两块网卡: 其 中VMnet1是虚拟机Host-only模式的网络接口,VMnet8是NAT模式的网络接口, ...