Posted April 24, 2013 by Giampiero Granatella

In this post we are going to see how to develop applications using IntelliJ Idea and Portofino 4. The traditional development of a web application in IntelliJ Idea 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 IntelliJ Idea, facilitates to create and edit xml pages, jsp and groovy scripts. With IntelliJ Idea we can debug Groovy scripts, browse and search classes, have syntax highlighting, auto-completion, import and automatic functions refactoring.

Note, during the realization of this post I used IntelliJ Idea 12 "Community Edition". 

Project setup

Within Idea, we create a new project.
Select Java Module, set the "Project Name" and use the war expanded under Tomcat (ROOT direcetory) as "Project Location". Then click on "Next"
You can skip Groovy configuration (we'll configure it later) and click on "Finish".
Now we set the project structure, we are going to set where sources will located (Groovy scripts)  and the libraries of our web project.
Click on the button "Project strucure."
For sources, click on "Modules" and set the directory "apps / default / groovy" as the source directory.
Again in the project structure, create a new library "lib" in which upload the jar is in the WEB-INF/lib directory and the jar in the lib directory of Apache Tomcat.
Now, our project is ready to be modified with IntelliJ Idea and Groovy scripts can use the colored code, the syntax checking and auto imports.

Remote debug


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

  1. configure Tomcat to start in debug mode
  2. configure Idea to connect to the remote server
For these steps you can refer to
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/ jpda start
Now configure the remote server IntelliJ Idea click on "Edit Configurations ...".
We define a new "Remote", give it a name and verify the host and the port (5005 is the value of the variable JPDA_ADDRESS previously set).
And that's it. Put a break point on the file security.groovy, we log in and see the debugging IntelliJ running.


In this post we configured Idea 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,  the configuration is similar to what done in this post.


comments powered by Disqus